JavaScript RegExp [abc] 表达式
JavaScript RegExp 对象
定义和用法
[abc] 表达式用于查找方括号之间的任何字符。
方括号内的字符可以是任何字符或字符范围。
语法
new RegExp("[abc]")
直接量语法:
/[abc]/
浏览器支持
所有主流浏览器都支持 [abc] 表达式。
实例
在字符串中对字符范围 [a-h] 进行全局搜索:
<html><body><script type="text/javascript">var str="Is this all there is?";var patt1=/[a-h]/g;document.write(str.match(patt1));</script></body></html>
结果是:
h,a,h,e,e