题目为正则表达式,需要注意EXACTLY的含义,即AAAAxBBB中x不满足条件,但aAAAxBBBa却满足条件。使用perl解决此题,利用s///替换字母,循环读取整个源码文件,结果为linkedlist。解答完毕,程序如下:
#!perl -w use 5.010; ############## Level 3 ############## # data store the sourcepage information open FILEIN, "data" or die "Can‘t open the data."; my $word = ""; while (<FILEIN>) { chomp; while ( $_ =~ s/(?<name1>[a-z])([A-Z]){3}(?<name2>[a-z])([A-Z]){3}(?<name3>[a-z])/$+{name2}AAA$+{name3}/ ) { $word .= $+{name2}; } } close FILEIN; print $word . "\n"; #################################