Welcome Guest, Not a member yet? Register   Sign In
Strange regex behaviour
#5

[eluser]BrianDHall[/eluser]
[quote author="aquariuz" date="1254845365"][0-23] means: 0 to 2, plus 3. So basically it means 0 to 3.
As soon as a 4 or higher appears in the first segment, the regular expression fails.[/quote]

Just wanted to confirm this as correct and elucidate.

Regex works on characters individually - to a regex there is no number greater than 9. 90 is not bigger than 9, because it is actually just a 9 and a 0 that happen to be next to each other.

To get a number less than one-hundred you might try, for instance "/[0-9][0-9]/" - but again it will not behave as expected as it will match the 1 and the 0 of the number 100.

A good site for regex as a reference: http://www.regular-expressions.info/


Messages In This Thread
Strange regex behaviour - by El Forum - 10-06-2009, 04:29 AM
Strange regex behaviour - by El Forum - 10-06-2009, 04:42 AM
Strange regex behaviour - by El Forum - 10-06-2009, 05:09 AM
Strange regex behaviour - by El Forum - 10-06-2009, 05:26 AM
Strange regex behaviour - by El Forum - 10-06-2009, 07:57 AM
Strange regex behaviour - by El Forum - 10-06-2009, 01:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB