我正在创建正则表达式以从日志文件中提取各种字段。我使用一些工具创建了一个正则表达式,它几乎完成了。唯一的问题是对于一个字段,它只提取一位数字而不是完整数字。为了更好地理解,我已将其保存到以下链接。
图案:
/(?=[^P]*(?:ParNew|P.*ParNew|PSYoungGen|DefNew))^(?:).*(?P<ParNew_before_1>\d)K\->(?P<ParNew_after_1>\d+)K\((?P<young_heap_size>\d+)K\), (?P<par_new_duration>\d+\.\d+) secs\] (?P<ParNew_before_2>\d+)K\->(?P<ParNew_after_2>\d+)K\((?P<total_heap_size>\d+)/
细绳:
146372.273: [GC146372.274: [ParNew: 378633K->88155K(419456K), 0.0313803 secs] 9893391K->9602913K(12478080K), 0.0320299 secs] [Times: user=0.32 sys=0.01, real=0.03 secs]
电流输出:
Full match `146372.273: [GC146372.274: [ParNew: 378633K->88155K(419456K), 0.0313803 secs] 9893391K->9602913K(12478080`
Group `ParNew_before_1` `3`
Group `ParNew_after_1` `88155`
Group `young_heap_size` `419456`
Group `par_new_duration` `0.0313803`
Group `ParNew_before_2` `9893391`
Group `ParNew_after_2` `9602913`
Group `total_heap_size` `12478080`
预期输出:
Full match `146372.273: [GC146372.274: [ParNew: 378633K->88155K(419456K), 0.0313803 secs] 9893391K->9602913K(12478080`
团体
ParNew_before_1
378633
Group `ParNew_after_1` `88155`
Group `young_heap_size` `419456`
Group `par_new_duration` `0.0313803`
Group `ParNew_before_2` `9893391`
Group `ParNew_after_2` `9602913`
Group `total_heap_size` `12478080`
在上面的示例中:ParNew_before_1
仅提取一位数字的组。