FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » how to change old ereg?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
PREG \d vs. [0-9] (was: how to change old ereg?) [message #181943 is a reply to message #181941] Wed, 26 June 2013 14:42 Go to previous messageGo to previous message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma:
Senior Member
Thomas 'PointedEars' Lahn wrote:
> Tony Mountifield wrote:
>
>> That's because you have an unescaped / within your regex, so it sees
>> /^M?(([0-9]?)[ ]?([0-9])(/ followed by a ? as a regex modifier.
>
> Good catch. Also, in POSIX Extended Regular Expressions (ERE) this is
> written simpler
>
> ^M?(([0-9]?) ?([0-9])(…
>
> and in Perl-Compatible Regular Expressions (PCRE) it is written simpler
>
> ^M?((\d?) ?(\d)(…

Isn't the exact interpretation of \d locale dependent? I was not able
to find this information on php.net and I am not able to verify this, as
I do not have locales available, which have decimal digits other than
0-9. However, at least when one works with UTF-8 encoded strings and
uses the u modifier for the regular expression, \d is not the same as [0-9]:

>>> $zero = "\xe0\xa5\xa6" // DEVANAGARI DIGIT ZERO
>>> preg_match('/[0-9]/u', $zero)
0
>>> preg_match('/\d/u', $zero)
1

--
Christoph M. Becker
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FORMS, validating mail was sent
Next Topic: $referrer = $_SERVER['HTTP_REFERER'] echo
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 00:25:44 GMT 2024

Total time taken to generate the page: 0.03937 seconds