Asif
Asif

Reputation: 5038

What will be the accurate Regular Expression for my String?

An example string:

AB-XYZ-123

Where:

AB : Any two capital alphabets only, no symbol, no numbers, no Small letter alphabets.

- : A - symbol only, nothing else.

XYZ: Any three capital characters capital letter alphabets combination.

- : A - symbol only, nothing else.

123: Any three numbers ([0-9]) combination.

and yeah I am very weak in creating regex.

Upvotes: 0

Views: 57

Answers (2)

Jens
Jens

Reputation: 25563

It is

^[A-Z]{2}-[A-Z]{3}-[0-9]{3}$

Upvotes: 2

juergen d
juergen d

Reputation: 204766

Try this one

^[A-Z]{2}-[A-Z]{3}-\d{3}$ 

Upvotes: 4

Related Questions