JasonDamianUs wrote:
> I want to check for a number that is greater then
499... the whole
> strring looks like this "(500 seconds)"
>
> I wrote this reg ex in two parts to check and it works,
but there must
> be a more elegant way to do it?
>
>
> \([5-9]\d{2,}.*seconds\)|\([1-4]\d{3,}.*seconds\)
It's better to factor out the opening parenthesis from the
front of the
alternation(for matching efficiency). and the non-greedy
form .*? might
be better than the greedy one .* in your pattern. But I
guess you need
\s* here. so,
another way of your pattern can be written
as(untested):
\((?:[5-9]|[1-9]\d+)\d\d\s*seconds\)
Xicheng
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
|