我有一个字符串,希望从中提取一个单词,并附加一个数字,该数字可能在每行中都不同:
This is string1 this is string
This is string11
This is string6 and it is in this line
我想解析这个文件并获取从0到100的"stringXXX"值。
# suppose ABC.txt contains the above lines
FH1 = open "Abc.txt";
@abcFile = <FH1>;
foreach $line(@abcFile) {
if ($pattern =~ s/string.(d{0}d{100});
print $pattern;
上面的代码会打印整行,我希望只获取字符串XXX。