2

All these questions are similar, having (my guess) a similar answer:

  1. The ereg functions, which are POSIX, have been DEPRECATED (as of PHP 5.3.0). So, why do we need to use POSIX, if the PHP community prefers PCRE regular expressions?

  2. The mb_ereg functions, which are also POSIX, are only for stay with mb_ prefix family of multi-byte functions?

  3. I have been used preg functions with UTF8-strings, and the /u option to UTF8-regex (!). Why not use only PCRE?

  4. There are an explicit (official) PHP documentation about when to use preg and when to use mb_ereg?


Related questions (they do not offer a direct answer):

Community
  • 1
  • 1
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
  • ERE and Perl regex have different syntax and works differently (the name `ereg` suggests that the `mb_ereg` uses ERE). I just don't know the syntax of `mb_ereg` family of function, though... – nhahtdh Jun 12 '13 at 04:51
  • 1
    First of all, `mb_ereg` is part of the *MB extension*, so not necessarily to be considered part of the core PHP and therefore not necessarily governed by the same people and deprecation processes. Even putting that aside though, `mb_ereg` seems to support arbitrary encodings via `mb_internal_encoding`; `preg_*` only supports UTF-8. Just my guesses though... – deceze Jun 12 '13 at 06:27
  • Thanks to both! ligthng the question and answers... I edited, enumerating the 4 "equivalent questions" (4 EQs). @deceze pointed a really good guess, addressing the EQ2. The Nhahtdh's comment about ERE is addressing the EQ1, and I suppose that what named "ERE" is what I named "POSIX". – Peter Krauss Jun 12 '13 at 12:06
  • @deceze _this feels weird -you likely know this now but maybe you didn't at the time_: please add an answer instead of a comment. Refer to the section **When _shouldn't_ I comment?** on [Comment everywhere](https://stackoverflow.com/help/privileges/comment). – Sᴀᴍ Onᴇᴌᴀ Sep 02 '20 at 19:01

0 Answers0