Jim
Jim

Reputation: 1

getting error: Warning: preg_match() [function.preg-match]: Unknown modifier ',' in

Here is the syntax I am trying to use to replace PHP5.3 problematic "if (ereg".

origianl code:

if (ereg('([0-9.-]{1,}),([0-9.-]{1,})', $location, $regs))

new code:

if (preg_match('/[0-9.-]{1,}/,/[0-9.-]{1,}/', $location, $regs))

this new code is causing the warning. I tried to figure it out using previous posts, here, but I am not quite getting it right.

Thanks.

Upvotes: -1

Views: 1422

Answers (1)

John Conde
John Conde

Reputation: 219804

You forgot to escape your slashes which are your regex delimiters:

if (preg_match('/[0-9.-]{1,}/,/[0-9.-]{1,}/', $location, $regs))

should be

if (preg_match('/[0-9.-]{1,}\/,\/[0-9.-]{1,}/', $location, $regs))

Upvotes: 4

Related Questions