我有以下内容:
my $str='"fld":{xyz..,"val":"x"},"fldA":{afd;ladf,"val":"valid y"},"fldB":{adsa;afda,"val":"invalid val x"}...';
my $fldNm="fldA";
if ( $str =~ /"$fldNm".*"val":"([^"]+)"/ ) {
print "\n Val = $1 \n";
}
匹配/打印“有效y”的正确正则表达式是什么
当前的正则表达式匹配“fldA”和贪婪匹配并跳过它的值,而是给我最后一个值:“invalid val x”
谢谢,
杰斯