0

Possible Duplicate:
How can I convert ereg expressions to preg in PHP?

The site I am working on has been migrated to a server using php 5.3.16 from 5.2.17 We have a problem with the function ereg being deprecated.

How can I resolve the issue with the following lines?

1) ereg("^[0-9]*$", $v[1])
2) ereg("^[-A-Za-z' ]+$", $v[4])
3) ereg("^4[0-9]{12}([0-9]{3})?$", $v[1])
4) ereg("^5[1-5][0-9]{14}$", $v[1])
5) ereg("^3[47][0-9]{13}$", $v[1])
6) ereg($exp, $value)
Community
  • 1
  • 1
Lawrence DeSouza
  • 984
  • 5
  • 16
  • 34
  • Use preg_* functions. on this case, [preg_match](http://www.php.net/manual/en/function.preg-match.php) instead ereg function. – felipsmartins Nov 15 '12 at 15:37
  • A Reference Question is: [How can I convert ereg expressions to preg in PHP?](http://stackoverflow.com/q/6270004/367456) - If you have problems to find the relating functions between ereg and pcre, the PHP manual has a translation table: [Differences from POSIX regex](http://php.net/reference.pcre.pattern.posix). See as well: [Function ereg_replace() is deprecated - How to clear this bug?](http://stackoverflow.com/q/3132844/367456) – hakre Nov 16 '12 at 09:12

1 Answers1

0
preg_match('/^[0-9]*$/', $v[1])
preg_match('/^[-A-Za-z\' ]+$/', $v[4])
preg_match('/^4[0-9]{12}([0-9]{3})?$/', $v[1])
preg_match('/^5[1-5][0-9]{14}$/', $v[1])
preg_match('/^3[47][0-9]{13}$/', $v[1])

Not sure how to handle the last one, the $exp needs to be a valid pattern:

Ray
  • 40,256
  • 21
  • 101
  • 138