本文介绍了c#和js的正则表达式模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
can i use same regex in c# that i have used in javascript
喜欢: -
like:-
private static bool IsValidEmail(string senderEmail)
{
var regExPattern_forEmail = new Regex(@"^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$");
return (string.IsNullOrEmpty(senderEmail) != true && regExPattern_forEmail.IsMatch(senderEmail) != true);
}
function validateEmail(objEmail)
{
var regExPattern_forEmail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
if (regExPattern_forEmail.test(objEmail.value) == false)
{
alert('\"' + objEmail.value + '\" is INVALID e-mail Address');
return false;
}
else
{
alert('\"' + objEmail.value + '\" is VALID e-mail Address');
return true;
}
}
推荐答案
function validateEmail(objEmail)
{
var regExPattern_forEmail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}
这篇关于c#和js的正则表达式模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!