Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex Pattern Help Please

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
0
0
US
Can anyone assist me in creating a necessary REGEX patter to verify that an entry is in the format of #####-#####?

The input is to be a range of numbers, so the part on the left needs to be less than the part on the right. The range must be separated by a hyphen. There can be any number of digits up to 5 on each side. All of the following would be valid:

1-25
100-199
1000-2000
31000-34000

I figured out how to use the regular expressions in my VB.net code, but formulating the expression is still eluding me.

Any help is greatly appreciated. Thank you.

 
Got this sorted out.
Code:
Function IsValid_Range(ByVal sRange As String)

        Return Regex.IsMatch(sRange, "^\d{1,5}-\d{1,5}$")

    End Function

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top