Regex to match numbers between 10 and 999

Discussion in 'Programming' started by blueparukia, Dec 19, 2009.

  1. #1
    Hi,

    I need some random regex (POSIX) to match a number between 10 and 999. So if the string is "140", "276" or "97", or any number between 10 and 999...it will return true.

    Cheers.

    EDIT: Got it.
     
    blueparukia, Dec 19, 2009 IP
  2. aratnaweera

    aratnaweera Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Was it something like this?

    - 10 to 999 without leading zeros:

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

    - 10 to 999 with possible leading zeros:

    ^0*[1-9][0-9]{1,2}$

    On UNIX shell tools (e.g.: grep, you may have to use backslash before { and }. E.g.: ^0*[1-9][0-9]\{1,2\}$.

    P.S. This is my first post here. :)
     
    aratnaweera, Dec 19, 2009 IP