struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Thompson <elephant...@gmail.com>
Subject Re: Regular expressions - Email Validation
Date Wed, 31 Mar 2010 18:19:51 GMT
Have you tried a simpler regex to make sure that validation is wired
up correctly?  The one you're currently using will reject valid email
addresses (e.g. local+part@example.com), and it will probably allow
invalid ones through (like localpart@example.a.a).

See
http://tools.ietf.org/html/rfc2822#section-3.4.1 and
http://www.regular-expressions.info/email.html.

-Brian



On Wed, Mar 31, 2010 at 12:19 PM, seeking_solution
<pankajj.jain@gmail.com> wrote:
>
> tried using -
>
> <constant-value>^([a-zA-Z0-9]([\w\.-]*[a-zA-Z0-9])*@[a-zA-Z0-9]([\w\.-&amp;]*[a-zA-Z0-9])*\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])[\s]*$</constant-value>
>
> OR
>
> <constant-value>^([a-zA-Z0-9]([\w\.-]*[a-zA-Z0-9])*@[a-zA-Z0-9]([\w\.-\&amp;]*[a-zA-Z0-9])*\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])[\s]*$</constant-value>
>
> still not working. validation xml deploys successfully but validation fails.
> not sure whats happening.
>
>
>
> seeking_solution wrote:
>>
>> In struts I have regular expression for validating email like this -
>> <constant>
>>           <constant-name>EMail</constant-name>
>>
>> <constant-value>^([a-zA-Z0-9]([\w\.-]*[a-zA-Z0-9])*[_]*@[a-zA-Z0-9]([\w\.-]*[a-zA-Z0-9])*\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])[\s]*$</constant-value>
>> </constant>
>>
>> Now I want to allow & in the email. I tried like this
>>
>> <constant-value>^([a-zA-Z0-9&]([\w\.-]*[a-zA-Z0-9&])*[_]*@[a-zA-Z0-9]([\w\.-]*[a-zA-Z0-9])*\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])[\s]*$</constant-value>
>>
>> OR
>>
>> <constant-value>^([a-zA-Z0-9]([\w\.-]*[a-zA-Z0-9])*[_]*@[a-zA-Z0-9]([\w\.-&]*[a-zA-Z0-9])*\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z])[\s]*$</constant-value>
>>
>> I also tried escaping special char using \&.
>>
>> But its not working. gives error at deploy time.
>>
>> Please help
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Regular-expressions---Email-Validation-tp28097766p28099106.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message