js正则表达式验证、匹配数字、匹配字符串、匹配中⽂、匹配任 意字符备忘录 正则表达式或“regex”⽤于匹配字符串的各个部分,下⾯是我创建正则表达式的备忘录。包括⼀些常⽤的验证、匹配数字、匹配字符串、匹配中⽂、匹配任意字符串。匹配正则 使⽤ .test() ⽅法 let testString = "My test string"...
使用字符类,你可以使用它来定义要匹配的一组字符 把它们放在方括号里 [] //匹配 "cat" "fat" and "mat" 但不匹配 "bat"constregexWithCharClass=/[cfm]at/g;consttestString="cat fat bat mat";constallMatchingWords=testString.match(regexWithCharClass);// ["cat", "fat", "mat"] 匹配字母表中...