Page 1 of 1

number bellow 2012 in a string

Posted: Mon Oct 24, 2011 6:13 am
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?

Re: number bellow 2012 in a string

Posted: Mon Oct 24, 2011 6:49 am
by Apollo

Code: Select all

rag/([01]?[0-9]{1,3}|20(0[0-9]|1[01]))[abc]

Re: number bellow 2012 in a string

Posted: Tue Oct 25, 2011 7:42 am
by basher400
I thank you very much