regex compilation error
Posted: Fri May 07, 2010 2:39 pm
Hi,
I'm moving code from one server to another and something that used to work no longer works.
On the OLD server, this worked just fine:
$agent="mozilla/5.0 (macintosh; u; intel mac os x 10.5; en-us; rv:1.9.2.3) gecko/20100401 firefox/3.6.3 firephp/0.4";
$pattern = '#(?<browser>msie|firefox|safari|chrome|opera)[/ ]+(?<version>[0-9]+(?:\.[0-9]+)?)#';
if (!preg_match_all($pattern, $agent, $matches))
// do something...
on the NEW server with the same code I get this error:
Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unrecognized character after (?< at offset 3 in [url removed] on line 78
I'm not an expert in regex or php. Any help or pointers greatly appreciated... Thanks!
I'm moving code from one server to another and something that used to work no longer works.
On the OLD server, this worked just fine:
$agent="mozilla/5.0 (macintosh; u; intel mac os x 10.5; en-us; rv:1.9.2.3) gecko/20100401 firefox/3.6.3 firephp/0.4";
$pattern = '#(?<browser>msie|firefox|safari|chrome|opera)[/ ]+(?<version>[0-9]+(?:\.[0-9]+)?)#';
if (!preg_match_all($pattern, $agent, $matches))
// do something...
on the NEW server with the same code I get this error:
Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unrecognized character after (?< at offset 3 in [url removed] on line 78
I'm not an expert in regex or php. Any help or pointers greatly appreciated... Thanks!