zl程序教程

您现在的位置是:首页 >  前端

当前栏目

菜鸟javascript基础资料整理3正则

JavaScript基础 整理 正则 菜鸟 资料
2023-06-13 09:14:25 时间
1.js正则表达式(RegExp对象)
RegExp对象有3个方法:test()、exec()以及compile()。
①test()方法
//test()方法检索字符串中的指定值。返回值是true或false。
varpatt1=newRegExp("e");
document.write(patt1.test("Thebestthingsinlifearefree"));
②exec()方法
//exec()方法检索字符串中的指定值。返回值是被找到的值。如果没有发现匹配,则返回null。
varpatt1=newRegExp("e");
document.write(patt1.exec("Thebestthingsinlifearefree"));
未完待续。