Regex testers return results but not my site

I have used two testers of regex, http://www.pagecolumn.com/tool/pregtest.htm and http://www.spaweditor.com/scripts/regex/ both return the results I want but when ever I go 'Live' I get no results.

Heres the script I'm trying to get working:

$ptn = "/\\x(..)/";
$str = "\x47\x4c\x4f\x42\x41\x4c\x53";
preg_match_all($ptn, $str, $matches, PREG_PATTERN_ORDER);
print_r($matches);

Anyone know where I'm going wrong?

Answers


PHP converts your $str string into its actual characters, you are actually testing the string "GLOBALS".

If you don't want escape sequences to be parsed, use single quotes:

$ptn = '/\\\x([0-9a-f]{2})/i';
$str = '\x47\x4c\x4f\x42\x41\x4c\x53';

Need Your Help

unix bc command and order of operation

unix math bc

I'm encountering a strange issue with the basic unix "bc" command on a mac and I want to just make sure I'm understanding it correctly. From the man pages, it says it respects order of operations,...

FileReference vs File?

actionscript-3 flash filereference

I want to make a Flash app in which the user can load and save files from and to their local hard drive. While I've often done this in AIR apps using the File and FileStream classes, I haven't done...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.