Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Regular expression

    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

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

    Thank You
    Last edited by pvpkiran; 03-18-2009 at 11:03 AM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Code:
    /^[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.
    Last edited by Philip M; 03-18-2009 at 11:36 AM.

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hey,
    Thanx for the reply.
    But the pattern u have given matches even this

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

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by pvpkiran View Post
    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.
    Last edited by Philip M; 03-18-2009 at 11:37 AM.

  • Users who have thanked Philip M for this post:

    pvpkiran (03-18-2009)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •