-1

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.

John Conde
  • 217,595
  • 99
  • 455
  • 496
Jim
  • 1
  • 3

1 Answers1

4

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))
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • @Jim: I'm not very familiar with `ereg`, but `\/` tries to match `/` literally which you don't seem to be doing in your original expression. Are you sure that is what you want? – Felix Kling Jan 21 '13 at 21:39