Jump to content

Preg / Ereg - what's the difference?


johnsmith153

Recommended Posts

I believe ereg will no longer be available in PHP6.

 

I have quite a few scripts to change, so want to get it right.

 

Ideally I will make the changes now.

 

Can I simply replace "ereg" below with "preg"?

 

The lines below are parts of a script that will need changing.

 

 

if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {

 

if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {

 

if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {

 

if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {

 

if (!ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$", $email_array[1])){

 

if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $emailtocheck))

Link to comment
https://forums.phpfreaks.com/topic/131442-preg-ereg-whats-the-difference/
Share on other sites

Oh, would you look at this.  A tutorial on regular expressions written by some anonymous upstanding individual who is not myself seems to have put a section on PCRE vs. POSIX-Extended in his tutorial!  http://www.phpfreaks.com/tutorial/regular-expressions-part1---basic-syntax/page7

 

What a great person.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.