菜鸟javascript基础资料整理3 正则
更新时间:2010年12月06日 20:34:01 作者:
js正则表达式(RegExp对象) 的使用。
1.js正则表达式(RegExp对象)
RegExp 对象有 3 个方法:test()、exec() 以及 compile()。
①test()方法
//test() 方法检索字符串中的指定值。返回值是 true 或 false。
var patt1=new RegExp("e");
document.write(patt1.test("The best things in life are free"));
②exec()方法
//exec() 方法检索字符串中的指定值。返回值是被找到的值。如果没有发现匹配,则返回 null。
var patt1=new RegExp("e");
document.write(patt1.exec("The best things in life are free"));
未完待续。
RegExp 对象有 3 个方法:test()、exec() 以及 compile()。
①test()方法
//test() 方法检索字符串中的指定值。返回值是 true 或 false。
var patt1=new RegExp("e");
document.write(patt1.test("The best things in life are free"));
②exec()方法
//exec() 方法检索字符串中的指定值。返回值是被找到的值。如果没有发现匹配,则返回 null。
var patt1=new RegExp("e");
document.write(patt1.exec("The best things in life are free"));
未完待续。
您可能感兴趣的文章:
相关文章
Javascript学习笔记之 函数篇(二) : this 的工作机制
与其他编程语言相比,Javascript 对 this 的使用是一套完全不同的机制。this 在五种情况下的值是各有不同的。2014-06-06


最新评论