- 第一章 简介和语法
- 1.1 简介和语法
- 第二章 元字符
- 2.1 元字符
- 第三章 修饰符和先后顺序
- 3.1 修饰符
- 3.2 操作符的优先级
- 第四章 实例
- 4.1 php常用正则函数
- 4.2 javascript 正则相关函数
- 4.3 常用正则表达式
4.2 javascript 正则相关函数
test() 方法检索字符串中的指定值。返回值是 true 或 false。
var patt1=/e/;
document.write(patt1.test("The best things in life are free"));
//输出:true
exec() 方法检索字符串中的指定值。返回值是被找到的值。如果没有发现匹配,则返回 null。
var patt1=/e/;
document.write(patt1.exec("The best things in life are free"));
//输出:e
compile() 既可以改变检索模式,也可以添加或删除第二个参数。
var patt1=/e/;
document.write(patt1.exec("The best things in life are free"));
patt1.compile("d");
document.write(patt1.exec("The best things in life are free"));
//输出:ed
上一篇:4.1 php常用正则函数
下一篇:4.3 常用正则表达式
评论
共0 条评论
没有更多了..