• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Regex

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

5250-5429

Thanks.
0
centricC
Asked:
centricC
1 Solution
 
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
 
ozoCommented:
^5(2[5-9]|3\d|4[0-2])\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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now