我想用 "xx:xx:xx" 替换 Perl 中 2 个字符串的 "hh:mm:ss" 的 reg 表达式我该怎么做?
代码:
use strict;
use warnings;
my $l="12:48:25 - Properties - submitMode : 2";
my $r="54:01:00 - Properties - submitMode : 2";
#my $newLn;
#Find "hh:mm:ss" in $_ :P
if ($l =~ /\d\d:\d\d:\d\d/ || $r=~ /\d\d:\d\d:\d\d/) {
#print "Time found";
s/\d\d:\d\d:\d\d/xx:xx:xx/g; #looking for default $_ , but have $l and $r
s/\d\d:\d\d:\d\d/xx:xx:xx/g;
#substitute with xx: p
print $l,"\n";
print $r,"\n";
} else {
print "No time found found";
}