phone number regular expression problem

Discussion in 'Perl Misc' started by venu, May 31, 2006.

  1. venu

    venu Guest

    Hi,
    I have a different requirement and it is :

    I need to validate a phone number field.
    It may or may not be a US phone number.

    The constraints are :
    ***********************

    # It should accept any number of numbers
    # any number of - hyphens
    # and one + symbol
    # no other characters and alphabets are allowed

    Thanks in advance

    Venugopal.S
     
    venu, May 31, 2006
    #1
    1. Advertising

  2. venu

    Ted Zlatanov Guest

    On 31 May 2006, wrote:

    > I need to validate a phone number field.
    > It may or may not be a US phone number.
    >
    > The constraints are :
    > ***********************
    >
    >> It should accept any number of numbers
    >> any number of - hyphens
    >> and one + symbol
    >> no other characters and alphabets are allowed


    Think about the problem and write good requirements (yours are really
    bad!). I hope this helps you more than a canned answer would.

    Ted

    p.s. real answer: look at Number::phone

    http://search.cpan.org/search?query=number::phone&mode=all
     
    Ted Zlatanov, May 31, 2006
    #2
    1. Advertising

  3. venu wrote:
    > Hi,
    > I have a different requirement and it is :
    >
    > I need to validate a phone number field.
    > It may or may not be a US phone number.
    >
    > The constraints are :
    > ***********************
    >
    > # It should accept any number of numbers
    > # any number of - hyphens
    > # and one + symbol
    > # no other characters and alphabets are allowed
    >


    You mean the following are acceptable phone numbers:
    "+"
    "----------------------"
    "12345+56789"
    "203980234092-091234-0918234-982-34989834-09283-098349821-0394-219384-02918-092834-012983490"

    but these are not:
    "800 723 9374"
    "(0234)23249"

    nor this:
    "08000 CONTACTS"

    I've assumed you actually meant "zero or one + symbol".
     
    RedGrittyBrick, May 31, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. joemono
    Replies:
    5
    Views:
    13,996
    Roy Johnson
    Oct 3, 2003
  2. VSK
    Replies:
    2
    Views:
    2,389
  3. Ori
    Replies:
    2
    Views:
    21,363
    Brian W
    Jan 26, 2004
  4. Jake K
    Replies:
    2
    Views:
    877
    Rad [Visual C# MVP]
    Jan 15, 2007
  5. venu
    Replies:
    4
    Views:
    167
Loading...

Share This Page