Error when Regexp tried to run

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

Moderator: General Moderators

Post Reply
User avatar
hydroxide
Forum Commoner
Posts: 77
Joined: Mon Jun 05, 2006 9:53 am

Error when Regexp tried to run

Post by hydroxide »

Why does this

Code: Select all

$date_range = "9/15/06-9/19/06";

$match_exp = "/(?<Month>\d{1,2})\/(?<Day>\d{1,2})\/(?<Year>(?:\d{4}|\d{2}))(?x)/";

preg_match_all($match_exp, $date_range, $dates_match);
Give me this error? (line 68 being the preg_match_all line)

Code: Select all

Warning: Compilation failed: unrecognized character after (?< at offset 3 in myscript.php on line 68
My regexp checks out with a testing program I'm using...

Any help would be appreciated.

EDIT:This doesn't work either.

Code: Select all

$match_exp = "(?<Month>\d{1,2})/(?<Day>\d{1,2})/(?<Year>(?:\d{4}|\d{2}))(?x)"
it says

Code: Select all

Warning: Unknown modifier '/' in myscript.php on line 68
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"(?<" is a lookbehind trigger.
Post Reply