var text = "testing: 1, 2, 3";
var pattern = /\d+/g;
pattern.test(text) //=>true :匹配成功
text.search(pattern);//=> 9:首次匹配成功的位置(从0开始计数)
text.match(pattern);//=>["1", "2", "3"]:所有匹配组成的数组
text.replace(pattern, ‘#‘);//=>"testing: #, #, #"
text.split(/\D+/);// => ["", "1", "2", "3"]:用非数字字符截取字符串
原文:http://www.cnblogs.com/jiaxu/p/4325454.html