How to insert the whole matched text in the replacement in Perl?

后端 未结 1 1697
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 07:25

I 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

相关标签:
1条回答
  • 2021-01-29 08:14

    Use $&, see http://perldoc.perl.org/perlvar.html

    echo 'aabbcc' | perl -p -e 's/bbc/$&A/g'
    

    aabbcAc

    0 讨论(0)
提交回复
热议问题