wind1211 发表于 2011-04-25 14:19

关于正则表达式的逆向引用

请问正则表达式中的逆向引用只支持9个group么?
我在javascript中1-9可以加上$就可引用,但是超过10以上的数字,就不能用这个$直接引用。
在shell中可以使用${} 来引用第10个以上的argument,但在正则表达式中用什么来引用呢?

jason680 发表于 2011-04-25 14:40

请问正则表达式中的逆向引用只支持9个group么?
我在javascript中1-9可以加上$就可引用,但是超过10以上的 ...
wind1211 发表于 2011-04-25 14:19 http://bbs.chinaunix.net/images/common/back.gif


一样是${n} ....
(很少用超过5个也....)

wind1211 发表于 2011-04-25 14:43

谢谢您的回复。
如下是我的测试字符串:
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
rb   swpd   free   buffcache   si   so    bi    bo   in   cs us sy id wa st
002336460632 576120 13213672    0    0   6    50    1    178 8410
102336461128 576128 13213696    0    0   0   420 1035 180718 8920
002336461624 576128 13213676    0    0   0    16 1047 192117 9100
202336461128 576128 13213676    0    0   0    88 1024 1841 119 8000

varoutput='';
var sum=0;
reg=/(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/gi;
while((res=reg.exec(input))!=null){
      output +=parseInt(RegExp.${15})+'\n';
   
}
output.toString();
提示如下错误:
missing ) after argument list (<cmd>#12)

wind1211 发表于 2011-04-25 14:56

关帖吧,JS中只能支持9个group的引用

我愿为你匍匐一生 发表于 2024-02-20 08:56

页: [1]
查看完整版本: 关于正则表达式的逆向引用