码农双双的博客如果想要在字符串 The dog chased the cat 中匹配到 the 这个单词,可以使用如下正则表达式:/the/。 注意,正则表达式中不需要引号。 let a =“The dog chased the cat” ; let b = /the/; b.test(a); 这里会打印...
一百个Chocolate的博客我们直接来看一下下面这个例子吧: let str = 'The words in the front-end include front and end, is front-end not frontend'; let reg = /front/gi; let res = str.match(reg); console.log(res); //