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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex Question 1

Status
Not open for further replies.

JurkMonkey

Programmer
Nov 23, 2004
1,731
CA
Been a while since I've done a good regex string.

What I'm doing is an input mask for a textbox. The data is a phone number which may, or may not include an extension.

123-456-7890
123-456-7890 ext:1234

I don't want the regex to output the ext: if it is not existent. Anyone feel like trying to put this regex string together for me?

Thanks!
 
Nevermind, I got it.

@"((\+[0-9\-\.\(\)]+)|((\d{3}-\d{3}-\d{4}))( ext:\d*){0,1})
 
Thanks for posting the solution JurkMonkey. :)

____________ signature below ______________
You are a amateur developer until you realize all your code sucks.
Jeff Atwood

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top