是否有替换后向引用被整个匹配替换?$0 似乎不起作用——它的内容总是-e",出于某种原因:$ echo 'aabbcc' |perl -p -e 's/bbc/$0A/g'氨基酸 解决方案 使用 $&,参见 http://perldoc.perl.org/perlvar.htmlecho 'aabbcc' |perl -p -e 's/bbc/$&A/g'aabbcAcI want to add a string (A) after all specific other strings (bbc). So, I match bbc and want to replace it with itself with A appended ('aabbcc' => 'aabbcAc').Is there a replacement back-reference that gets substituted with the whole match?$0 doesn't seem to work – its content is always "-e", for some reason:$ echo 'aabbcc' | perl -p -e 's/bbc/$0A/g'aa-eAc 解决方案 Use $&, see http://perldoc.perl.org/perlvar.htmlecho 'aabbcc' | perl -p -e 's/bbc/$&A/g' aabbcAc 这篇关于如何在 Perl 的替换中插入整个匹配的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-07 17:19