RegEx Help

F

Franklin

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.
 
H

Hans Liss

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
 
G

Göran Andersson

Franklin said:
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$
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Tasks 1
HELP PLEASE 4
Processing in Python help 0
Logic Problem with BigInteger Method 2
RegEx Help 2
Help with code 0
Regex Issues - Qualified URLS 0
Regex help 6

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top