Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在perl中用回车替换行?_Perl - Fatal编程技术网

如何在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