亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - How to write this regular rule to match a string that does not start with a certain character?
PHP中文網(wǎng)
PHP中文網(wǎng) 2017-06-12 09:21:00
0
6
877

Language: JavaScript

is required to match hello, but cannot match abchello. How should I write this regular rule? Have no idea ...

PHP中文網(wǎng)
PHP中文網(wǎng)

認(rèn)證0級(jí)講師

reply all(6)
小葫蘆
console.log(/\bhello\b/.test('abchello')); // false
console.log(/\bhello\b/.test('hello')); // true
漂亮男人

/^hello$/, you may want qui to match the word hello, but not other words containing hello. In this case, you only need one hello, or write it with abc and return false. You can also write two

Ty80

js does not have lookahead, it can only be determined through two matches.

我想大聲告訴你

/^hello$/ig.test('abchello'); //false
/hello$/ig.test('abchello'); //true

Cause:

^這個(gè)特殊字符表示以什么開始,如果想要隨意匹配就將其去掉。
 同樣地,$這個(gè)特殊字符是結(jié)束標(biāo)志。
世界只因有你

Personally, I think it’s better to use /bhellob/, but this regular rule cannot be matched very accurately. It can only satisfy most situations, not special situations. This is because js’s support for regular expressions is not perfect enough, so you can make do with it for now

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template