wrangler
wrangler

Reputation: 3576

Regex for String with first two characters fixed and rest digits

Is there a regular expression for? :

Eg: https://regex101.com/r/PufypE/1

The expression i tried

\^(UE|ue){2}[0-9]{6}\

but its not working (no match found!)

Upvotes: 0

Views: 2534

Answers (2)

sniperd
sniperd

Reputation: 5274

You want:

\b(UE|ue)[0-9]{6}\b

You don't need the {2} next to the (UE|ue) since you are specifying those exactly. The \b is a word boundary so this will match a list like you put in the comment: UE123456,ue654321 This is a good site to play with a regex on for this kind of stuff: http://regex101.com

Upvotes: 1

anubhava
anubhava

Reputation: 785196

Regex should be:

^[Uu][Ee][0-9]{6}$

(UE|ue){2} in your regex would match 2 occurrences of UE or ue

Upvotes: 1

Related Questions