Build regular expression with hex characters

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
number45
Forum Newbie
Posts: 3
Joined: Sun Mar 08, 2009 1:15 pm

Build regular expression with hex characters

Post 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.
mintedjo
Forum Contributor
Posts: 153
Joined: Wed Nov 19, 2008 6:23 am

Re: Build regular expression with hex characters

Post by mintedjo »

If you only need to append hex characters 81 and 17 then what is the \x00 for?
Post Reply