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

Help with a regular expression

Options
  • 28-12-2007 7:18pm
    #1
    Closed Accounts Posts: 324 ✭✭


    Hi
    Please help

    This is my regular expression:
    \$(\d*?)(\.*?)(\d*?)

    (a dollar, followed by 0 or more digits, followed by ., followed by 0 or more digits).

    I just need to check that the string is no longer than say 8 characters long, including the numbers, . and dollar sign.

    I know how to restrict the length of any string to 8 letters
    ^.{1,8}$
    but I'm having trouble combing this with the first expression


    Help!:D


Comments

  • Registered Users Posts: 11,980 ✭✭✭✭Giblet


    ^\$[0-9]{0,2}$

    Start from that


  • Closed Accounts Posts: 324 ✭✭radioactiveman


    This seems to be working :

    ^[\$(\d*?)(\.*?)(\d*?)]{1,8}$

    The square brackets make the difference, I'll have to look this up:confused:


  • Registered Users Posts: 11,980 ✭✭✭✭Giblet


    The square brackets are groupings, you should probably have one for each side of the decimal.


Advertisement