RegExp对象
同 Array、Function、Object一样, RegExp表示JavaScript中一类数据。
1 如何创建正则表达式 (创建RegExp对象)
- RegExp直接量方式
/html5/
- RegExp构造函数
new RegExp("html5")
- RegExp() 函数
RegExp("html5")
2. RegExp对象的方法
exec()
检索字符串中指定的值。返回找到的值,并确定其位置。test()
检索字符串中指定的值。返回 true 或 false。