How can I write a regex pattern with Perl that will work like that:
**If there is a 开发者_Go百科new line**, after it, it will remove that new line character and all the whitespace characters after until it sees any character except for a white space character and will put just one whitespace character instead of them?
substitution operator
use warnings;
use strict;
my $s = "foo\n bar goo\nber";
$s =~ s/\n\s*/ /g;
print "$s\n";
__END__
foo bar goo ber
I am not sure if I understand your question well. Try: s{ \n\s+ }{ }gx
精彩评论