1

I am using Jquery email Regex for validation as below:

@"^((([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])))$"

Not sure why it does not allow for uppercase?! If email address should not contain any upper case or anything is wrong here.

1
  • 1
    That's an ugly regular expression, you should look at html5 and also jquery form validation plugin if you want better syntax. Commented Oct 4, 2012 at 10:46

1 Answer 1

4

Everywhere you have an occurence of [a-z] character class, simply change it into [a-zA-Z]

(or specify the case insensitive flag/modifier i in your regexp)

Sign up to request clarification or add additional context in comments.

5 Comments

Using the i flag is probably the least painful approach in this case.
yep, indeed the flag is the simpler solution
Thanks, but wondering why Jquery just validate lowercase for eamil addresses?
there's no Jquery in what you posted. that is only a PCRE pattern, nothing more, nothing less :)
@patricgh: what you posted is a string, too, not a RegExp object (yet), perhaps when the constructor is called i is passed as a second argument, to make the expression case-insensitive

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.