Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

reg ex help

  • 31-08-2007 7:43am
    #1
    Registered Users, Registered Users 2 Posts: 6,240 ✭✭✭


    hello

    I want to validate a phone number
    the logic is as follows

    0 or 1 '+'

    followed by at least 6 digits and as many spaces in between

    so I had this expression
    [+]?\\s]*[\\d{6,}$
    so [+]? = + once or not at all
    and [\s]*[\d]{1} (lets call this A)= zero or more whitespace charaters followed by a 1 digit
    [A]{6,0} = A to be true at least 6 times

    but yet the phone number
    77 77 comes back as true
    even though I'm looking for 6 digits

    any body any clue of where my logic is wrong?


Comments

  • Closed Accounts Posts: 8 sure22


    Once regex sees square brackets it tries to match one of the items in the brackets, I think this is where your problem lies. Try this instead
    [+]?\\s*\\d{6,}$


  • Closed Accounts Posts: 8 sure22


    Doh! with the round brackets

    [+]?(\\s*\\d\\s*){6}$


Advertisement