I am using asp.net (c#) and for validation of an email address field, I have the following regular expression:
[RegularExpression("^[a-zA-Z0-9_\\.-]+@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$"]
This doesn't sound right to allow spaces and you will trim off later, the regex is helping that scenario and providing that validation (although you should still check server side)
I think adding (\\s*)
at the beginning and end should help you though. i.e.
[RegularExpression("^(\\s*)[a-zA-Z0-9_\\.-]+@([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}(\\s*)$")]
This is saying start or ends with whitespace