//因为返回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; } }