摘要: 1 // String对象的4个使用正则表达式的方法 2 3 1、match(pattern) 4 返回pattern中的子串或null 5 2、replace(pattern,replacement) 6 用replacement替换pattern 7 3、search(pattern) 8 返回字符串中pattern开始位置 9 4、split(pattern)10 返回字符串指定pattern拆分的数组11 12 13 14 //使用match方法获取匹配数组15 16 var pattern=/Box/i; //没有开启全局17 var... 阅读全文
posted @ 2013-10-20 23:28 白小虫 阅读(531) 评论(0) 推荐(0) 编辑
摘要: 1 var box=new RegExp('Box'); //第一个参数是模式字符串 2 alert(box); // /Box/两个反斜杠是正则表达式的字面量表示法 3 4 5 var box=new RegExp('Box','gi'); //第二个参数可选,是模式修饰符 6 alert(box); 7 //模式修饰符的可选参数 8 // i 忽略大小写 9 // g 全局匹配10 // m 多行匹配11 12 13 var box=/Box/; //使用字面量方式的正则14 alert(box);15 16 17 var box=/Box/ 阅读全文
posted @ 2013-10-20 23:01 白小虫 阅读(607) 评论(0) 推荐(0) 编辑