By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

regular expression help

P: n/a


Hi guys,

I need to do some validation and I am not that great at regular
expressions.

What would the regexp be for
optional digit 1 or 2 followed by any digit followed by a dot followed
by either a 1 or a 2 followed by one optional letter (M, C, L, or S) and
one optional digit 1, 2, or 3 (letter may be followed by digit, but if
no letter, only one digit)?

That is, the following are valid:
d.d
d.dl
d.dld (letter must be m,c,l,s and last d must be 1,2,or 3)
dd.d (first d must be 1 or 2)
dd.dl
dd.dld

Thanks for any help...

-------------------------------------------------
~kaeli~
All I ask for is the chance to prove that money
cannot make me happy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
kaeli <in********************@NOSPAMatt.net> wrote in
news:MP************************@nntp.lucent.com:
What would the regexp be for
optional digit 1 or 2 followed by any digit followed by a dot followed
by either a 1 or a 2 followed by one optional letter (M, C, L, or S) and
one optional digit 1, 2, or 3 (letter may be followed by digit, but if
no letter, only one digit)?

That is, the following are valid:
d.d
d.dl
d.dld (letter must be m,c,l,s and last d must be 1,2,or 3)
dd.d (first d must be 1 or 2)
dd.dl
dd.dld


/[12]?\d\.[12]([mcls][123]?)?/i
Jul 20 '05 #2

P: n/a
In article <Xn********************@194.109.133.29>, no**@none.nl
enlightened us with...

/[12]?\d\.[12]([mcls][123]?)?/i


Thanks!
--
-------------------------------------------------
~kaeli~
All I ask for is the chance to prove that money
cannot make me happy.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.