Jump to content

seems so simple.


scs

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/138370-seems-so-simple/
Share on other sites

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];

Link to comment
https://forums.phpfreaks.com/topic/138370-seems-so-simple/#findComment-723556
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.