关于function已经找到答案document.close(); document.open();var str = "123abc"; str = str.replace(/(.)(.)(.)/g, function(all, one, two, three) { document.write("all:" + all + "<br/>"); document.write("one:" + one + "<br/>"); document.write("two:" + two + "<br/>"); document.write("three:" + three + "<br/>"); });((-\d+)+)这加号是不是有点多余?
\d+ 匹配 1~n个数字 ((-\d+)+) 1~n个 -\d+
var string = "-2-3-6-7-6"; var number = /(-\d)+/g; document.write(string.match(number));var string = "-2-3-6-7-6"; var number = /-\d+/g; document.write(string.match(number));
document.open();var str = "123abc";
str = str.replace(/(.)(.)(.)/g, function(all, one, two, three) {
document.write("all:" + all + "<br/>");
document.write("one:" + one + "<br/>");
document.write("two:" + two + "<br/>");
document.write("three:" + three + "<br/>");
});((-\d+)+)这加号是不是有点多余?
\d+ 匹配 1~n个数字
((-\d+)+) 1~n个 -\d+
var number = /(-\d)+/g;
document.write(string.match(number));var string = "-2-3-6-7-6";
var number = /-\d+/g;
document.write(string.match(number));