PracticeDev/study_perl/re/9re.pl

14 lines
445 B
Perl
Raw Permalink Normal View History

2022-12-20 17:31:11 +08:00
#!/usr/bin/perl
#
$txt="1234ab56";
$txt =~ /\d\d/g;
print "matched $&: ",pos $txt,"\n";
$txt =~ /\d\d/g;
print "matched $&: ",pos $txt,"\n";
$txt =~ /\G\d/gc; # 匹配失败,指针卡在原地
print "matched $&: ",pos $txt,"\n";
$txt =~ /\G\d/gc; # 匹配失败,指针继续卡在原地
print "matched $&: ",pos $txt,"\n";
$txt =~ /\G\d/gc; # 匹配失败,指针继续卡在原地
print "matched $&: ",pos $txt,"\n";