NYCPHP Meetup

NYPHP.org

[nycphp-talk] Regex & Delimiter Trouble

Daniel J Cain Jr. dan at cain.sh
Fri Nov 19 16:15:36 EST 2004


Given this script:

<?php
$pattern = "/^quantity[1-9][0-9]{0,2}$/";
$haystack = "quantity11";
echo (preg_match($haystack, $pattern)) ? 'We got one!': 'DOH!', "\n";
?>

I hope to match quantity1 ... quantity999, but PHP5 on Mac OS X outputs 
the following from the CLI:

Warning: preg_match(): Delimiter must not be alphanumeric or backslash 
in /Users/djcain/regex on line 4
DOH!

I've been trying to get around the issue for quite some time now and I 
think I'm unable to see the forest through the trees :)

The warning seems pretty straightforward but for the life of me I'm 
unable to grasp what it want's for the delimiter.  Anyone out there 
dealt with this issue before, or see the problem that I apparently do 
not?

-dan




More information about the talk mailing list