Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by sk (Curate)
on Nov 26, 2005 at 18:20 UTC ( #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!


Comment on Re: How to remove \n between two words but retain one space
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-09-21 16:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls