1

I change ereg to preg_match for update mycode to PHP5.3 . now i see this warning in my page. how to fix this ?

warning :

Warning: preg_match() [function.preg-match]: Unknown modifier '-' in C:\xampp\htdocs\share\configs\functions.php on line 2645

old Code :

if (!ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $dateOfBirth, $regs))

New Code (PHP 5.3):

if (!preg_match ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $dateOfBirth, $regs))

Thanks

BBKing
  • 2,279
  • 8
  • 38
  • 44
  • possible duplicate of [preg_match_all() \[function.preg-match-all\]: Unknown modifier '\]'](http://stackoverflow.com/questions/396557/preg-match-all-function-preg-match-all-unknown-modifier) and many others, have a look at the "Related" list on the right side. – Felix Kling Jul 26 '12 at 08:51

1 Answers1

3

You need to add delimiters:

if (!preg_match ("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/", $dateOfBirth, $regs))
#                 ^                                    ^
Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452