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

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,670
    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,959
    Rep Power
    1014
    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.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo