语言:JavaScript
要求匹配 hello
,但不能匹配 abchello
,这个正则该怎么写?想不出来 ...,,,
console.log(/\bhello\b/.test('abchello')); // false
console.log(/\bhello\b/.test('hello')); // true
/^hello$/ig.test('abchello'); //false
/hello$/ig.test('abchello'); //true
原因:
^这个特殊字符表示以什么开始,如果想要随意匹配就将其去掉。
同样地,$这个特殊字符是结束标志。
2 回答1.4k 阅读✓ 已解决
1 回答682 阅读
1 回答672 阅读
js 只有后瞻,so 写不了 ...