Jump to content


Photo

ereg vs. preg


  • Please log in to reply
5 replies to this topic

#1 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 15 June 2006 - 12:51 AM

I've been wondering, between the two sets of functions, which one(s) should I should when coding a script that is intended to be distributed?

PCRE is often considered faster - and better - than the POSIX set, but the Manual says:
"Regular expression support is provided by the PCRE library package..."

This means there are chances of some server don't support them, right? Should I have this in mind and use ereg? To further increase confusion, here is some weird discussion about

"Move ereg to PECL"
[a href=\"http://www.php.net/~derick/meeting-notes.html#move-ereg-to-pecl\" target=\"_blank\"]http://www.php.net/~derick/meeting-notes.h...ve-ereg-to-pecl[/a]

What should I do?
Thanks [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
~ D Kuang

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 15 June 2006 - 04:12 PM

This is covered in "Mastering Regular Expressions." In a nutshell, POSIX was an attempt at standardization. One positive is that is uses locales; however, this is alleviated when tools work with Unicode. Then came Perl, and thus PCRE, which really spiffed up regular expressions capabilities.

See [a href=\"http://en.wikipedia.org/wiki/Regular_expressions\" target=\"_blank\"]http://en.wikipedia.org/wiki/Regular_expressions[/a].
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 gentooman

gentooman
  • New Members
  • Pip
  • Newbie
  • 2 posts
  • LocationLouisiana

Posted 31 August 2008 - 04:43 AM

Hello Poirot,
I have always used PCRE and I have never had any problems with support. Also, I just read somewhere, possibly the "Mastering Regular Expressions" Third edition thread, that support for POSIX regular expressions might be dropped from PHP 6.  I think that speaks for itself. Also, if you need to write a script in Perl you will feel at home.
Education is whatever you have left after forgetting everything you learned.

#4 DarkWater

DarkWater
  • Members
  • PipPipPip
  • Advanced Member
  • 6,175 posts
  • LocationNew York

Posted 31 August 2008 - 12:52 PM

Hello Poirot,
I have always used PCRE and I have never had any problems with support. Also, I just read somewhere, possibly the "Mastering Regular Expressions" Third edition thread, that support for POSIX regular expressions might be dropped from PHP 6.  I think that speaks for itself. Also, if you need to write a script in Perl you will feel at home.


Actually, those talks were finalized.  POSIX is being dropped from PHP6 and will ONLY be available through PECL, while PCRE CANNOT be removed after PHP5.3.
Info:Apache 2.2.4 | PHP 6.0.0-dev, PHP 5.2.4 | Ubuntu 8.04 | Age: 16 | Coding PHP and CSS+(X)HTML: 5-6 years | Feel free to PM me if you need help!
Αν χρειάζεσαι ένας μεταφραστής, μπορέις να μου μιλάς.  Μιλώ καλά.

If you ask for a banana, would you expect someone to hand you an orange? Or a fork?  No you wouldn't, because you asked for a banana, and you expect them to understand that a banana is not an orange or a fork.  It's the same principle.


#5 nrg_alpha

nrg_alpha
  • Staff Alumni
  • Advanced Member
  • 2,498 posts
  • LocationCanada's Capital

Posted 31 August 2008 - 01:33 PM

How does a thread that is two years old get revived? lol
"Build a man a fire, you warm him for a day. Set a man on fire, and he'll be warm for the rest of his life."
PHP = One cool palindrome!

#6 DarkWater

DarkWater
  • Members
  • PipPipPip
  • Advanced Member
  • 6,175 posts
  • LocationNew York

Posted 31 August 2008 - 01:53 PM

How does a thread that is two years old get revived? lol


LOL I didn't even notice that, I just posted because I saw it at the top of the board.  Ahahaha.
Info:Apache 2.2.4 | PHP 6.0.0-dev, PHP 5.2.4 | Ubuntu 8.04 | Age: 16 | Coding PHP and CSS+(X)HTML: 5-6 years | Feel free to PM me if you need help!
Αν χρειάζεσαι ένας μεταφραστής, μπορέις να μου μιλάς.  Μιλώ καλά.

If you ask for a banana, would you expect someone to hand you an orange? Or a fork?  No you wouldn't, because you asked for a banana, and you expect them to understand that a banana is not an orange or a fork.  It's the same principle.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users