#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Posts
    2,568
    Rep Power
    171

    A Regex quesiton. Validating only allowing numbers and 1 white space


    Hello;

    I need a simple regex to validate for phone numbers with only numberds and 1 white space. For example:

    Valid: 0405 333 535
    Invalid:0405 333 535 (Devshed removes 2 white spaces!). It is supposed to be 0405  333 535

    Thanks
    Last edited by zxcvbnm; March 12th, 2013 at 07:30 AM.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,911
    Rep Power
    1045
    Hi,

    the exact format of course depends on your location, but in general, the regex for multiple sequences of at least one digit separated by single spaces is simply

    Code:
    /\d+(?: \d)+/
    There's a regex forum, by the way.

IMN logo majestic logo threadwatch logo seochat tools logo