如何在perl中用回车替换行?
如何在下面的文字墙中找到并替换这两行如何在perl中用回车替换行?,perl,Perl,如何在下面的文字墙中找到并替换这两行 wall of text authorize { update request { } wall of text 我试过了,但没用。问题在于回车 perl -p0e "s/authorize \{\nupdate request \{//" ~/test 试试这个: perl -p0e "s/\s*authorize \{\n\s*update request \{\n\s*\
wall of text
authorize {
update request {
}
wall of text
我试过了,但没用。问题在于回车
perl -p0e "s/authorize \{\nupdate request \{//" ~/test
试试这个:
perl -p0e "s/\s*authorize \{\n\s*update request \{\n\s*\}//o" ~/test
您是否尝试过
\r\n
?此外,在“更新请求”前面有空白,您在regexYes中没有考虑这些空白。有很多空白。有没有一种方法可以在不计算它们的情况下在正则表达式中捕获它们<代码>\r\n没有什么不同。这很有效。我注意到在我原来的问题中,updaterequest{
之后我遗漏了一个结束括号。你能在你的回答中包括这个吗?我想我知道了:perl-p0e“s/\s*authorize\{\n\s*updaterequest\{\n\s*}//o”~/test