Perl5 里面的正则表达式特性
A 锚位匹配字符串的绝对开头
m{Ahttps?://}i
z 锚位匹配字符串的绝对末尾
m{.pngz}i
他允许后面出现换行符。
while(<STDIN>){ print if /.png/; } /As*/ #匹配一个空行
^ 行首
$ 行末
^ 和 $ 锚位可以和/m修饰符表示对多行
$_= 'This is a wilma line barney is on another line but this ends in fred and a final dino line'; /fred$/m /^barney/m
如果没有/m,^和$的行为就如同A和z一样。
单词锚位
是单词边界锚位,它能匹配单词的首尾
/fred/ #可匹配fred,但无法匹配frederick alfred manfredmann /hnunt/ #来匹配hunt hunting或hunter
非单词边界锚位B,它能匹配所有不能匹配的位置
/searchB/ #会匹配searches searching 与 searched,但不能匹配search