I'm looking for a regex to validate initials. The only format I want it to allow is:
(a capital followed by a period), and that one or more times
Valid examples:
A.
A.B.
A.B.C.
Invalid examples:
a.
a
A
A B
A B C
AB
ABC
Using The Regulator and some websites I have found the following regex, but it only allows exactly one upper (or lower!) case character followed by a period:
^[A-Z][/.]$
Basically I only need to know how to force upper case characters, and how I can repeat the validation to allow more the one occurence of an upper case character followed by a period.
You almost has it right: +
says "one or more occurenses" and it's \.
, not /.
Wrapping it in ()
denotes that it's a group.
^([A-Z]\.)+$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With