2.3.2 grok 正则捕获:

\s+ 和 [\n\t\r\f]+ 一样  


1、命名分组格式为(?<grp name>),反向引用时用\k<grp name>

2、命名分组的匹配的结果存在在变量%+变量中,取命名分组值,$+{grp name}.


zjtest7-frontend:/root/0825# cat a1.pl 
my $str="  begin 123.456 end  ";
if ($str =~/(?<request_time>\d+\.\d+)/)
   {
    my ($request_time) = ($+{request_time});  
   print $request_time."\n";};
zjtest7-frontend:/root/0825# perl a1.pl 
123.456


zjtest7-frontend:/root/0825# cat a1.pl 
my $str="  begin 123.456 end  ";
if ($str =~/(?<request_time>\w+\s+\d+)/)
   {
    my ($request_time) = ($+{request_time});  
   print $request_time."\n";};
zjtest7-frontend:/root/0825# perl a1.pl 
begin 123