本文转自:91博客 :原文地址:http://www.9191boke.com/235792704.html 正则表达式或“regex”用于匹配字符串的各个部分,下面是我创建正则表达式的备忘录.包括一些常用的验证.匹配数字.匹配字符串.匹配中文.匹配任意字符串. 匹配正则 使用 .test() 方法 let testString = "My test string"; let testRegex = /string/; testRegex.test(testString); 匹配多个模…
var pattern=/g..gle/; //点符号表示匹配除了换行符外的任意字符 var str='g78gle'; alert(pattern.test(str)); var pattern=/go*gle/; //o* ,表示0个或者多个o var str='goooooooooooogle'; alert(pattern.test(str)); var pattern=/go+gle/; //o+,表示一个或者多个o var str='gogle'; alert(pattern.tes…