htmlheadscripttype="text/javascript"//由于该字符串中存在字母"e",以上代码的输出将是:truevarpatt1=newRegExp("e");document.write(patt1.test("Thebestthingsinlifearefree"));//exec()方法检索字符串中的指定值。返回值是被找到的值。如果没有则返回null。varpatt1=newRegExp("e");document.write(patt1.exec("Thebestthingsinlifearefree"));//在使用"g"参数时,exec()的工作原理如下://找到第一个"e",并存储其位置//如果再次运行exec(),则从存储的位置开始检索,并找到下一个"e",并存储其位置//输出eeeeeeenullvarpatt1=newRegExp("e","g");do{result=patt1.exec("Thebestthingsinlifearefree");document.write(result);}while(result!=null)//compile()方法用于改变RegExp。//compile()既可以改变检索模式,也可以添加或删除第二个参数。varpatt1=newRegExp("e");document.write(patt1.test("Thebestthingsinlifearefree"));patt1.compile("d");document.write(patt1.test("Thebestthingsinlifearefree"));//由于字/符串中存在"e",而没有"d",以上代码的输出是://truefalse/script/headbody/body/html
评论发表评论
您还没有登录,请登录后发表评论(快捷键Alt+S/Ctrl+Enter)yelang2009换音题图意见
通过网页搜索本博客最近访客博客分类其他分类最近加入圈子存档最新评论评论排行榜声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。若作者同意转载,必须以超链接形式标明文章原始出处和作者。
0 评论:
发表评论