scs Posted December 25, 2008 Share Posted December 25, 2008 I have a expression which finds a hexadecimal thats 32 charaters long. Im just using match all to make sure it finds what im looking for. I want my end result to be just a preg match. preg_match_all('((#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?).{32})', $content, $output); It finds it out of the 135 lines. Most of the lines are not even hexadecimal.. Well I have a simple solution but cant figure how to do it. Theres another 8 hexadecimal set that I already know. The 8 is infront of the 32. So example [ 8 ][ 32 ] d7d8v94314619d326c74fe875f26d4561c4c662e So my question is how to I add the 8 in front of my expression? I've tried.. preg_match_all('(' . $hex_8 . ')((#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?).{32})', $content, $output); preg_match_all('(~' . $hex_8 . '~)((#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?).{32})', $content, $output); I used ~ cause I saw someone use it in another expression. All I get is an error. Like Warning: preg_match_all() [function.preg-match-all]: Unknown modifier '(' Any ideas? Thnx Quote Link to comment https://forums.phpfreaks.com/topic/138370-seems-so-simple/ Share on other sites More sharing options...
.josh Posted December 25, 2008 Share Posted December 25, 2008 Okay so basically what you're saying is that you're trying to find a 40 character alpha-numeric string, and you know the first 8 characters, right? $prefix = 's32dwds3'; // example prefix $string = 's32dwds3k34os098dfsnw2lknc9832lknd8h7d3y'; // example string preg_match('~'.$prefix.'(\w{32})~',$string, $match); echo $string . "<br/>"; echo $match[1]; Quote Link to comment https://forums.phpfreaks.com/topic/138370-seems-so-simple/#findComment-723556 Share on other sites More sharing options...
scs Posted December 26, 2008 Author Share Posted December 26, 2008 wow it was even more simple than I thought.. I need some work in regex Super thnx! ;D Quote Link to comment https://forums.phpfreaks.com/topic/138370-seems-so-simple/#findComment-723739 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.