Regex to validate initials

Posted by iar on Stack Overflow See other posts from Stack Overflow or by iar
Published on 2010-06-16T09:50:25Z Indexed on 2010/06/16 9:52 UTC
Read the original article Hit count: 294

Filed under:

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.

© Stack Overflow or respective owner

Related posts about regex