Regex

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

5250-5429

Thanks.
centricCAsked:
Who is Participating?
 
ozoCommented:
^5(2[5-9]|3\d|4[0-2])\d$
0
 
Terry WoodsIT GuruCommented:
5(2[5-9]\d|3\d\d|4[0-2]9)
0
 
farzanjCommented:
Try:
(?:52[5-9]\d|53\d{2}|54[012]\d)
0
 
Terry WoodsIT GuruCommented:
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 :-)
0
 
Derek JensenCommented:
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)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.