Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to remove \n between two words but retain one space

by sk (Curate)
on Nov 26, 2005 at 18:20 UTC ( [id://511936]=note: print w/replies, xml ) Need Help??


in reply to How to remove \n between two words but retain one space

my $str = "Hello\n\t\n World\n"; print $str; $str =~ s/\s+/ /g; print $str;

Output

Hello World Hello World

Update: Please note this replaces all whitespace chars to a single space char. So if you have leading/trailing spaces please go with Your Mother's solution!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://511936]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-19 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found