Perl Regex To Condense Multiple Line Breaks

前端 未结 4 1962
醉话见心
醉话见心 2021-01-14 10:24

I can\'t seem to figure out the right syntax but I want a Perl regular expression to find where there are two or more line breaks in a row and condense them into just 2 line

4条回答
  •  半阙折子戏
    2021-01-14 10:46

    Show a full example. What is $string?

    $ perl -E'my $s = qq{a\n\n\nb}; say "[$s]"; $s =~ s/\n\n+/\n\n/g; say "[$s]"'
    [a
    
    
    b]
    [a
    
    b]
    

提交回复
热议问题