Is there any way to make Custom own email regular expression?
Actually I want to create one registration form in php and for email validation,
I want to make my own customized email regular expression. For example,lets say I want to check that the given mail is name-number@ves.ac.in
.
It should only accept email id that ends with ves.ac.in
and should notify if given mail is not matching with expression. I did lot of experiment on:
^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$
but this expression but failed. please help.
The right regex could be this: ^([a-zA-Z0-9_\\-\\.]+)@ves\\.ac\\.in$
Here's a regex-tester
if you are validating with jQuery or javascript, then you can validate using
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if(!filter.test(email)){
// add error here
}
To check for a particular domain eg, (yahoo.com):
regx = /^[^@\s]+@yahoo\.com$/i;
regx.test(input);
//returns true if it matches
check this fiddle here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.