• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regular Expression to validate email address and allow only with .com and .asia

 
Vinod Vijay
Ranch Hand
Posts: 162
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to put a regular expression in the struts validation xml to validate email address which as .com and .asia enter by user. For example, to allow email address such as vinod@test.com and vinod@test.asia only. I tried a lot with following regular expression but still .asia is not working at all (.com is working) :-

Struts validator xml:-
<var><var-name>mask</var-name><var-value>^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{2,4}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{2,4}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{2}|com|asia~]*$</var-value></var>

I changed the regular expressiont o following as well:-
^([a-z0-9][-a-z0-9_\+\.]*[a-z0-9])@([a-z0-9][-a-z0-9\.]*[a-z0-9]\.(com|asia)|([0-9]{1,3}\.{3}[0-9]{1,3}))*$

But still it is not allowing email address with .asia?

Kindly advise.

Thank you
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35535
402
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain what you think this does?
|com|asia~]*$
I dont' undersatnd what the tilde is for, nor why it is in share brackets nor why there is an * (zero or more) flag at the end.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!