0

Possible Duplicate:
Using a regular expression to validate an email address

I am using email address validation in my code and for that I am using a Regex. Can anyone suggests me a regex which will not accept email addresses eg. abc@def.commmmmm or abc@xyz.com.com.com or abc@gmail.c.

Please help me.

thanks any information is valuable for me.

Community
  • 1
  • 1
Akki
  • 1,718
  • 2
  • 29
  • 53

1 Answers1

1

REGEXP =

 /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,

i have used in validation engine as well as custom js file.

TheFoxLab
  • 704
  • 1
  • 5
  • 22
  • Thanks...! I hope this will omit name@domain.com.com – Akki Nov 01 '12 at 10:47
  • Nice, can you explain me which rules it uses ? - No two dots after the @ - No longer extenstion (.com) then .. ? - ... Kind regards – Segers-Ian Nov 01 '12 at 10:53
  • I have checked for it but it accepts name@domain.com.com..I want which doesnt accepts this – Akki Nov 01 '12 at 10:53
  • @lan S : it is email validation of jquery validation engine. @Akki : sorry i haven't solution email like... `abc@test.com.com` ..!! :( – TheFoxLab Nov 01 '12 at 11:21