如果是数字,如何增加匹配结果?

时间:2016-01-28 11:30:10

标签: javascript jquery regex

我有这个字符串:

var string = "this is test
               1. this is test
               2. this is test
               3. this is test
              this is test
               1. this test   
               2. this is test
              this is test";

我也有这个正则表达式:

var match = /^[\s\S]*(?:^|\r?\n)\s*(\d+)(?![\s\S]*(\r?\n){2})/m.exec(string);

所以match[1]2。现在我需要增加那个结果。 (我想要3)。我怎么能这样做?

该regext与2匹配。换句话说:

alert(match[1]); //=> 2

现在我需要增加这个数字。我的意思是我想要这样的东西:

match[1]++; //=> I want: 3

我该怎么做?

0 个答案:

没有答案
相关问题