简体   繁体   English

如何在 perl 中用回车替换行?

[英]How to replace lines with carriage return in perl?

How can I find and replace those two lines within the wall of text below?如何在下面的文字墙中找到并替换这两行?

wall of text
    authorize {
            update request {
            }
wall of text          

I tried this, but it didn't work.我试过这个,但它没有用。 The problem is with the carriage return.问题在于回车。

perl -p0e  "s/authorize \{\nupdate request \{//" ~/test

try this:尝试这个:

perl -p0e "s/\s*authorize \{\n\s*update request \{\n\s*\}//o" ~/test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM