简体   繁体   English

有什么办法可以为电子邮件创建自定义正则表达式,例如我想使用abc@xyz.com而不是abc@gmail.com。

[英]is there any way to make Custom Own regular expression for email, like i want to go with abc@xyz.com instead of abc@gmail.com.?

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, 实际上,我想在php中创建一个注册表格并进行电子邮件验证,

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 . 例如,让我说我要检查给定的邮件是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. 它仅应接受以ves.ac.in结尾的电子邮件ID,并应通知给定的邮件是否与表达式不匹配。 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$ 正确的正则表达式可能是: ^([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 如果您正在使用jQuery或javascript进行验证,则可以使用

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): 要检查特定的域,例如(yahoo.com):

 regx =  /^[^@\s]+@yahoo\.com$/i;
 regx.test(input);
 //returns true if it matches

check this fiddle here . 在这里检查这个小提琴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将本地电子邮件截断为“abc...@gmail.com” - How to truncate an email local-part to 'abc…@gmail.com' 查找 [abc] 但不查找 [;;abc] 的正则表达式 - Regular expression that finds [abc] but not [;;abc] 接受两种格式的电子邮件,即abc.def和abc.def@testdomain.com - Email to be accepted in 2 formats i.e. abc.def AND abc.def@testdomain.com 当我访问www.example.com/abc时会发生什么 - What exactly happens when I go to www.example.com/abc 如何使用 PHP 在 abc.domain.com 或 abc.sub.domain.com 中检测“abc”? - How to detect "abc" in abc.domain.com or abc.sub.domain.com using PHP? mysql-从xyz选择电子邮件,其中email =“%gmail.com” - mysql - select email from xyz where email=“%gmail.com” 从mysite(xyz.com)向其他站点(abc.com)提交表单时如何重定向或发送一些变量? - How to Redirect or send some variable while submitting form from mysite (xyz.com) to other site (abc.com)? 会话值使用curl传递到另一个项目,并以“ {{abc @ gmail_com”:null}”格式接收该值 - Session value is passed using curl to another project and the value is received in “{”abc@gmail_com“:null}” this format 我有数据“ test1 @ gmail.com,test2 @ gmail.com”如何使结果看起来像这样 - i have data “test1@gmail.com,test2@gmail.com” how to make the result look like this 如何发送邮件至 abc@gmx.com - How to send mail to abc@gmx.com
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM