RegExp也在封锁英国.英国将被封锁
RegExp is also blocking UK when .UK is ment to be blocked
这是我的RegExp
function wordInString(s, word){
return new RegExp( '''b' + word + '''b', 'i').test(s);
}
var about=jQuery('#compdesi').val();
var education=jQuery('#educationhistory').val();
if((wordInString(about, '@')==true) || (wordInString(about, '.com')==true) || (wordInString(about, '.co')==true) || (wordInString(about, '.org')==true) || (wordInString(about, '.net')==true) || (wordInString(about, '.info')==true) || (wordInString(about, '.au')==true) || (wordInString(about, '.uk')==true) || (wordInString(about, '.ac')==true))
{
alert("You can not enter website, email or phone number in about");
return false;
}
这是在屏蔽英国网站和英国网站我做错了什么!
m使用测试作为文本:-
他出生于英国迈阿密的一个艺术家家庭,对他的绘画产生了深远的影响。现在经常在非洲。
.
在正则表达式中的意思是"任何字符"。
使用"''.uk"
将此函数更改为:
function wordInString(s, word){
return new RegExp( '''b''''' + word + '''b', 'i').test(s);
}
正如dystroy所说,除了需要双重转义外,请尝试以下行:
if ((wordInString(about, '@'))
|| (wordInString(about, '''.com'))
|| (wordInString(about, '''.co'))
|| (wordInString(about, '''.org'))
|| (wordInString(about, '''.net'))
|| (wordInString(about, '''.info'))
|| (wordInString(about, '''.au'))
|| (wordInString(about, '''.uk'))
|| (wordInString(about, '''.ac')))
相关文章:
- Html/Javascript-如何屏蔽除英国以外的所有欧盟国家,并允许所有非欧盟国家
- 什么是英国电话号码验证表达式和语法
- 使用英国日期标准dd/mm/yyyy计算两个日期之间的差异
- 英国邮政编码谷歌API不返回街道地址
- 英国银行排序代码 JavaScript 正则表达式
- 将长日期转换为英国短日期格式 dd/mm/yyyy
- PHP preg_replace 到 JavaScript |英国广播公司
- 英国排除了邮政编码正则表达式失败
- 返回英国邮政编码只是谷歌地图地理编码结果的一部分
- 将多个英国邮政编码列表添加到谷歌地图
- 使用正则表达式重新格式化包含英国邮政编码的字符串
- 英国邮政编码的 JavaScript 正则表达式
- 英国语言环境短格式和长格式的“Intl.toLocaleTimeString”行为不一致
- 按英国日期对 jQuery 数据表进行排序,忽略空单元格
- 启动日期选择器日期比较错误(英国/美国格式错误)
- Regex匹配英国邮政编码
- 更快地封锁Express中的所有路线
- 适用于英国移动设备的Javascript正则表达式
- 谷歌地图API V3英国地区
- RegExp也在封锁英国.英国将被封锁