• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Ranch Hand
Posts: 165
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41093
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic