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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.