number bellow 2012 in a string

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
basher400
Forum Newbie
Posts: 5
Joined: Mon Mar 27, 2006 1:17 am

number bellow 2012 in a string

Post by basher400 »

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?
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: number bellow 2012 in a string

Post by Apollo »

Code: Select all

rag/([01]?[0-9]{1,3}|20(0[0-9]|1[01]))[abc]
basher400
Forum Newbie
Posts: 5
Joined: Mon Mar 27, 2006 1:17 am

Re: number bellow 2012 in a string

Post by basher400 »

I thank you very much
Post Reply