0

I need a regex to exclude certain characters such as 'ç' and also to check '@' sign is present. Can someone help?

I am using jquery to do client-side validation using the following expression:

(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[\w-]{2,4}$/)
J. Steen
  • 15,470
  • 15
  • 56
  • 63
jqs
  • 82
  • 3
  • 10
  • May I suggest http://www.regexlib.com, unless you have a regex of your own that you've written and that you need help with? – J. Steen Jul 25 '11 at 20:34
  • 2
    `ç` is a legal character in an email address. – BalusC Jul 25 '11 at 20:39
  • ATM I am using (/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[\w-]{2,4}$/) but how do I exclude the character mentioned above? – jqs Jul 25 '11 at 20:46
  • Yes, I am aware that it is a legal character but due to system constraints I have to exclude... – jqs Jul 25 '11 at 20:49

1 Answers1

5

Chiefly:

function isAValidEmailAddress(emailAddress){
     return /^[a-z0-9_\-\.]{2,}@[a-z0-9_\-\.]{2,}\.[a-z]{2,}$/i.test(emailAddress);
}

Use http://en.wikipedia.org/wiki/Email_address#Syntax for a better regular expression.

Darm
  • 5,581
  • 2
  • 20
  • 18