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

How to build a regex for three unknown following numbers

Last post 06-24-2011, 9:32 AM by kerando. 4 replies.
Sort Posts: Previous Next
  •  06-15-2011, 1:31 PM 82993

    How to build a regex for three unknown following numbers

    Is it possible to create one single regex that matches all these strings?

    "2,3,4"

    "17,18,19"

    "44,45,46"

    In other words, three following numbers separated by commas!

    The numbers may be limited to 2 digits.

    I'd be glad if anyone can help!

  •  06-15-2011, 3:38 PM 82998 in reply to 82993

    Re: How to build a regex for three unknown following numbers

    try

    ^\d{1,2}(,\d{1,2})*$

  •  06-18-2011, 10:48 AM 83290 in reply to 82998

    Re: How to build a regex for three unknown following numbers

    Hi, thanks for the response!

    I tested your solution, it matches three comma separated numbers, that's half the way :)

    But sorry I haven't been clear enough - what I'd like to know is if it's possible to match directly following numbers (in the natural ascending order and not like this: 3,5,4).

    So there has to be an increment by one for each number in the regex ... somehow!

    Do you know what I mean?

  •  06-18-2011, 10:06 PM 83292 in reply to 83290

    Re: How to build a regex for three unknown following numbers

    Regular Expressions do not understand the context of your data,  http://regexadvice.com/blogs/mash/archive/2007/06/01/Are-you-ready-for-regex_3F00_.aspx

    Regexes have no concept of numbers.  Everything is just a string.

    In the future please provide the information requested in the posting guidelines when asking a question.  Thanks


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
  •  06-24-2011, 9:32 AM 83306 in reply to 83292

    Re: How to build a regex for three unknown following numbers

    Alright, that was clear.. wasn't sure about that.

    Next time I'll abide by the posting guidelines.

    Thanks!
View as RSS news feed in XML