Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

number bellow 2012 in a string

Last post 10-26-2011, 12:34 AM by mash. 2 replies.
Sort Posts: Previous Next
  •  10-24-2011, 7:12 AM 84112

    number bellow 2012 in a string

    hi

    I have strings like:
    "rag/1998a"
    "rag/2007c"
    "rag/2008a"
    "rag/2008b"
    "rag/2012a"
    "rag/2013a"
    "rag/2212c"

    the last letter can be either "a" , "b" or "c"

    I need to capture all stings which the nubmer in them is smaller than 2012
    for example , these should match my regexp:
    "rag/1998a"
    "rag/2007c"
    "rag/2008a"
    "rag/2008b"

    the other will not.

    what's the regexp for that?
    I tried this:
    "rag/[0-2011][abc]"

    didn't work.
    help please?

  •  10-25-2011, 9:42 PM 84119 in reply to 84112

    Re: number bellow 2012 in a string

    The number is Date?

    try this

    "rag/(1\d{3}|200\d|201[01])[abc]"

     

  •  10-26-2011, 12:34 AM 84122 in reply to 84112

    Re: number bellow 2012 in a string

    Regexes have no concept of numbers, only characters.

    You are trying to use the character class incorrectly. http://regexadvice.com/blogs/mash/archive/2008/01/31/A-touch-of-Character-Class.aspx


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
View as RSS news feed in XML