For me, this regular expression is incorrect:
^([0]?[1-9])$
^(0?[1-9])$
0? optionally match a zero
[1-9] match one of the characters between 1 and 9
I want the match to be from 01 to 09 -or- 01 to 80
EDIT:
Regex Engine
PCRE: not work
^[0]{1}?[1-9]$
Boost.Regex: work
^[0]{1}?[1-9]$
Regex: Search for numbers
-
- Posts: 18
- Joined: Sat Apr 11, 2020 2:45 pm
Re: Regex: Matching number ranges
Hi.. Here's two ways to PCRE-match: Any2Digits from 01-80
Alternates:
^([0][1-9]|[1-7][0-9]|80)$
.. 01-09.. |..10-79.. |80
NegatedLookArounds:
^(?!00)([0-8][0-9])(?<!8[1-9])$
Not00->(00 thru 89)<-Not 81-89
Without regex enabled, both examples need quoting because of the | < ! characters:
regex:"^([0][1-9]|[1-7][0-9]|80)$"
regex:"^(?!00)([0-8][0-9])(?<!8[1-9])$"
Hope it helps.. Cheers!
Alternates:
^([0][1-9]|[1-7][0-9]|80)$
.. 01-09.. |..10-79.. |80
NegatedLookArounds:
^(?!00)([0-8][0-9])(?<!8[1-9])$
Not00->(00 thru 89)<-Not 81-89
Without regex enabled, both examples need quoting because of the | < ! characters:
regex:"^([0][1-9]|[1-7][0-9]|80)$"
regex:"^(?!00)([0-8][0-9])(?<!8[1-9])$"
Hope it helps.. Cheers!
Re: Regex: Search for numbers
Ah, that is important.Without regex enabled, both examples need quoting because of the | < ! characters
I didn't read down far enough & tried & tried but couldn't get it to work.
So I split it up, which was fine as far as it goes,
regex:^[0][1-9]$|regex:^[1-7][0-9]$|regex:^80$
Then I was like, if mine works, what was I doing wrong with your example?
I was using regex: rather than setting, Search | Enable Regex.