[KLUG Members] Standard Regular Expressions (REs)

Vernon members@kalamazoolinux.org
Mon, 24 Mar 2003 09:25:53 -0500


Does anyone know of a list of "standard REs" that one might use to 
validate the characters used in,
for example, an e-mail address, a phone number (domestic or 
international), or a URL?

We are looking for a list that folks have thought about.  Probably not a 
list that strictly follows the
RFCs, because my suspicion is that "reality" does not exactly follow the 
RFCs.  Either the RFC is
more or less strict than the implimentations which are commonly accepted 
(i.e. some standard).

To give a more concrete example of what we are looking for, something 
like this

social security number
\d{3}-\d{2}-\d{4}
phone number
\(\d{3}\) (\d{3}-\d{4})
e-mail
[\w\.\-]+@[\w\.\-]+

But notice, one of these messy characters, [~!@#$%^&*()_+=],
may also be "allowed" in an e-mail address, so the REs just listed could 
be better.

Vernon

P.S.  What are the "less frightening" differences between REs in Java 
and Perl?