Page 1 of 1

Build regular expression with hex characters

Posted: Wed Mar 18, 2009 5:38 am
by number45
I'm using regular expressions to find data in a hex file. To find a certain set of data I need to append the hex characters 81 and 17 to the regular expression that I have built to ensure it is the correct data I find. When I try and do this however the expression stops matching.

Code: Select all

preg_match('/' . $map_name . '\x00\x81\x17/Uis', $data)
$map_name is a variable containing a value from a database that I want to check for. Without the hex characters in the preg_match this does match the data but with them nothing is found.

Is this something to do with how I am noting the hex characters.

Re: Build regular expression with hex characters

Posted: Wed Mar 18, 2009 11:53 am
by mintedjo
If you only need to append hex characters 81 and 17 then what is the \x00 for?