PracticeDev/study_perl/re/9re.pl

14 lines
445 B
Perl

#!/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";