Locked Regular Expression For US Phone Number in C#?

  • Thursday, October 01, 2009 7:13 AM
     
     
    Hello friends,

    If you know regular expression for US phone validation please let me know. I have used

    ^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$  expression . But it is fine for 10 digit numbers validation. I may have 12 digit numbers like 23-456-213-765  .  What is the regular expression for this?

All Replies

  • Thursday, October 01, 2009 9:32 AM
     
     
    You can edit the existing or add another one to validate the number. Each \d{3} \d{2} you see refers to the digits that are allowed to be inserted between the - or the . so all you have to do, is increase that number to allow more digits to be used.
    The only think i understand is what i feel..
  • Thursday, October 01, 2009 9:50 AM
     
     Proposed
    • Proposed As Answer by Cyborgx372 Monday, May 17, 2010 6:11 PM
    •  
  • Thursday, October 01, 2009 1:05 PM
     
     Proposed
    \((?<AreaCode>\d{3})\)\s*(?<Number>\d{3}(?:-|\s*)\d{4})
    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    • Proposed As Answer by Cyborgx372 Monday, May 17, 2010 6:11 PM
    •  
  • Monday, November 08, 2010 3:15 PM
     
     
    This might help

    http://www.regexlib.com/Search.aspx?k=phone
    http://www.regexlib.com/

    Why I cannot open the link here? Is the problem with the my network here?


    Why are you resurrecting a dead thread?

    Date asked: Thursday, October 01, 2009 7:13 AM


    John Grove - DSS, Senior Software Engineer
  • Friday, February 04, 2011 11:33 PM
     
     

    @John: one word. traffic.

    Sharon is just a spam bot who add vague words to replies and hope the hidden seo link added into the page's HTML source get undetected.

    Please edit your quote to remove the hidden seo link from the word "might" added by the bot.

     



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
  • Sunday, February 13, 2011 11:47 AM
     
     

    Hi pal

    I think this can help :

    http://msdn.microsoft.com/en-us/library/ff650303.aspx

     

    thx: Rambod Taati

  • Friday, May 18, 2012 11:29 AM
     
     
    Thank you... for link...