问题
i am using
var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
for validation check in a contact form in ActionScript3.
The problem is that if the email submitted starts with a numeric character then it is rejected. for example the email 45yah.yah@yahoo.com is rejected but the mail yah45.yah@yahoo.com is acceptable.
what should i change?
回答1:
var emailExpression:RegExp = /^[\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
BTW, did you try this?
回答2:
you might also find http://gskinner.com/RegExr/ useful for creating regexp solutions to stuff like this
回答3:
Here is one that does not fail with q.com email addresses.
function isValidEmail(email:String):Boolean {
var emailExpression:RegExp = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
return emailExpression.test(email);
}
来源:https://stackoverflow.com/questions/5713603/valid-email-in-actionscript-3