Reputation: 75127
How can I write a regex pattern with Perl that will work like that:
**If there is a 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?
Upvotes: 1
Views: 11373
Reputation: 62037
use warnings;
use strict;
my $s = "foo\n bar goo\nber";
$s =~ s/\n\s*/ /g;
print "$s\n";
__END__
foo bar goo ber
Upvotes: 3
Reputation: 74202
I am not sure if I understand your question well. Try: s{ \n\s+ }{ }gx
Upvotes: 2