Xicheng Jia wrote:
> Xicheng Jia wrote:
> > Cuperman wrote:
> > > Hi all,
> > > I need a regex to validate a field for
"any integer" OR "(any integer,
> > > any integer)"
> > > So i have this: {[0]*}|{\([0]*.[0]*}
> > This pattern matches only , , or {(0A0000}
^_^ ..... which is
=> sorry, the opening brace is a metacharacter, so it
matches
please neglect the above words, I forgot to remove them from
my
scripts.. ..
___[snip]___
> > completely different from what you wanted as
"any integer" OR (any
> > integer, any integer)
> > (Will double check this pattern after I get to my
office..)
>
___[snip]___
> my $pattern = qr{
> ^(?:
> # beginning of the string
> -?(?:\d|[1-9]\d+)
> # any positive or negative integer
> |
> # or
> \(
> # any positive integer x and y
> (\d|[1-9]\d+)
> ,\s*
> (\d|[1-9]\d+)
> # grouped in the form of (x, y)
> \)
=> (?(?{ $1 >= $2 })(?!))
Just found you want "X > Y" instead of
"X < Y", so the above line
should be changed to:
(?(?{ $2 >= $1 })(?!))
sorry for such confusions.
Xicheng
> # if x >= y, failed
> )$
> # end of string
> }x;
>
__[snip]__
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|