Link to home
Start Free TrialLog in
Avatar of centricC
centricC

asked on

Regex

Can someone help me write a regex for the following number range?

5250-5429

Thanks.
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

5(2[5-9]\d|3\d\d|4[0-2]9)
Try:
(?:52[5-9]\d|53\d{2}|54[012]\d)
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Correction to mine:

5(2[5-9]\d|3\d\d|4[0-2]\d)

Actually ozo's pattern is even better... I'd just go with that :-)
Yeah, except he may not be searching just the number; he may be searching a string for these numbers...if that's the case, try this:

(?<!\d)5(2[5-9]|3\d|4[0-2])\d(?!\d)