...

View Full Version : Resolved Regular expression



pvpkiran
03-18-2009, 11:56 AM
:confused:Hi all,
Can anyone provide me with the regular expression matching
this pattern
xx.xx

where x can be alpha numeric . But thr shud be only 2 letters or digits or combination of both. Not 1 or not more than 2

example
x.xx
xx.xxx
shud not match

I tried this , but didnt work


/([A-Z]|[a-z]|[0-9]){2}:([A-Z]|[a-z]|[0-9]){2}/

Help me out

Thank You

Philip M
03-18-2009, 12:22 PM
/^[a-z0-9]{2}\.[a-z0-9]{2}$/i


Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems." — Jamie Zawinski.

pvpkiran
03-18-2009, 12:29 PM
Hey,
Thanx for the reply.
But the pattern u have given matches even this

xx.xxx
xx.xxxxx
and xx.xx.xxxx

Philip M
03-18-2009, 12:35 PM
Hey,
Thanx for the reply.
But the pattern u have given matches even this

xx.xxx
xx.xxxxx
and xx.xx.xxxx

Sorry, you did not make it clear (or I did not grasp) that that the regex should match the xx.xx pattern and nothing else.

See amended regex above.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum