正则特殊字符后台与前台页面2种方式content = content.Replace("/\r\n/g", ""); content = content.Replace

前端之家收集整理的这篇文章主要介绍了正则特殊字符后台与前台页面2种方式content = content.Replace("/\r\n/g", ""); content = content.Replace前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

//因为返回JSON中存在\ 故正则一下
jsonStr = Regex.Replace(jsonStr,@"[\\]+","");



content = content.Replace("/\r\n/g","");

content = content.Replace("/\n/g","");
content = content.Replace("\r\n","");
content = content.Replace("\n","");
content = content.Replace("/'/g","\"");//‘'
//content = content.Replace(""","\"");//‘'

content = content.Replace("'","\"");//‘'


其他和下面前段JS基本一样,js正则函数match、exec、test、search、replace、split

下面我刚实现:后台

//content = Regex.Replace(content,@"[\""]+","'");

//content = Regex.Replace(content,@"[\-]+","");

下面我刚实现:前台
function TestDemo(re,s){
var s1;
if (re.test(s))
s1 = " 匹配正则式 ";
else
s1 = " 不匹配正则式 ";
return("'" + s + "'" + s1 + "'"+ re.source + "'");
}
window.onload = document.write(TestDemo(/ab/,'cdef'));



public bool formemail(string email) { string emailstr = email; //Regex ret = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"); Regex ret = new Regex(@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"); if (ret.IsMatch(emailstr)) { return true; } else { return false; } }

猜你在找的正则表达式相关文章