#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Exactly 9 digits


    I made this (JavaScript) regex:
    ^0\d{1,3}\s*/*\d{2,3}\s*\.*\d{2,3}(\s*\.*\d{2})?$
    It works as expected, only: it matches strings containing 10 digits too while the total number of digits should always be exactly 9.
    Is it possible to add that control to this regex ?
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Originally Posted by ivanh
    Is it possible to add that control to this regex ?
    No. Extract the digits with capturing groups and check the sum of their lengths using JavaScript.
    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