RegEx Help

Discussion in 'ASP .Net' started by Franklin, Feb 18, 2009.

  1. Franklin

    Franklin Guest

    I need to come up with a regex that tests for conformance to the following
    example:

    UA-123456-7

    To match, the string :
    - must start with "UA-" (upper case only)
    - followed by exactly six unsigned integers (each can be zero through nine)
    - followed by exactly one dash ("-")
    - followed by exactly one integer (which can be zero through nine)

    Thanks.
     
    Franklin, Feb 18, 2009
    #1
    1. Advertising

  2. Franklin

    Hans Liss Guest

    In article <#>, Franklin <> wrote:
    >I need to come up with a regex that tests for conformance to the following
    >example:
    >
    >UA-123456-7
    >
    >To match, the string :
    >- must start with "UA-" (upper case only)
    >- followed by exactly six unsigned integers (each can be zero through nine)
    >- followed by exactly one dash ("-")
    >- followed by exactly one integer (which can be zero through nine)



    Try
    ^UA-[0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]$

    This will work with any regular expression dialect.

    /H
     
    Hans Liss, Feb 18, 2009
    #2
    1. Advertising

  3. Franklin wrote:
    > I need to come up with a regex that tests for conformance to the following
    > example:
    >
    > UA-123456-7
    >
    > To match, the string :
    > - must start with "UA-" (upper case only)
    > - followed by exactly six unsigned integers (each can be zero through nine)
    > - followed by exactly one dash ("-")
    > - followed by exactly one integer (which can be zero through nine)
    >
    > Thanks.
    >


    That was a much more precise specification that you usually see. :)

    ^UA-\d{6}-\d$

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    Göran Andersson, Feb 18, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    735
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,660
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    618
  4. Xah Lee
    Replies:
    1
    Views:
    959
    Ilias Lazaridis
    Sep 22, 2006
  5. Replies:
    3
    Views:
    808
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page