1

I'm trying to make a regular expression that will match an e-mail address. The address must start and end with a letter, and a period must have two letters before and after it.

Here is a part of my expression so far before the @ symbol:

^[A-Za-z0-9]+[A-Za-z0-9\'\-\_]*(([A-Za-z]{2})+(\.([A-Za-z]){2})+)*[A-Za-z0-9]+ 

The problem I'm having is if a user enters simply two letters, a period, and another two letters; ab.cd, it validates as false since it's still looking for that starting letter.

abc.def validates just fine for example.

So my question is, is there any way to have it match the starting letter only if it is not followed by another letter? And vice-versa for the ending letter.

Thanks guys.

NoRest
  • 11
  • 1
  • http://stackoverflow.com/questions/201323/how-to-use-a-regular-expression-to-validate-an-email-addresses – alex vasi May 04 '12 at 16:50

1 Answers1