Re: [SLUG] Standard Regular Expressions (REs)

From: Vernon (vsingleton@cfl.rr.com)
Date: Mon Mar 24 2003 - 11:57:30 EST


Levi Bard wrote:

>
>
>>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.
>>
>>
>
>I would definitely follow the RFC, and reject anything nonstandard.
>

What standards other than RFCs do you use?
Do they contain lists of REs for validating these things?

>For an email, I might use '[^ ]+@[^ ]+' , since characters like
>underscores are definitely allowed.
>

Have you ever noticed that real life does not conform with the RFCs?

>A phone number's more difficult,
>since there are so many ways people delineate phone numbers. +011 83 44
>55, 18135551212 1-(813) 555-1212,813.555.1212, and so on. Maybe the best
>thing to do would be to extract the numeric characters from the string (it
>sounds like you want to verify a string from a user or a text field), and
>verify that there are at least 7 digits, and not more than a predetermined
>maximum, 10 or 11(if the 1- is added) for a domestic number, I have no
>idea for international.
>

Let's not build the list ourselves, if it already exists.

Again, what we are looking for is a list of "accepted" REs for
validating things like SS#, e-mail addresses,
international phone numbers, and URLs. Lots of MTAs reject underscores
in the first part of an e-mail
address according to folks on other lists.

Vernon



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:12:26 EDT