in reply to How to remove \n between two words but retain one space
Something like this will do it.
my $str = "George Best "; $str =~ s/(?<=[[:alpha:]])(?:\s\s+|[^\S ]+)(?=[[:alpha:]])/ /g; print "'$str'\n";
(update: took off the pointless "s" from the s///) That might be more complicated (someone else might have a better one?) that than you need but I think it's good and will also fix things like--
It will not fix leading and trailing spaces. Just spacing between alpha characters.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to remove \n between two words but retain one space
by JediWizard (Deacon) on Nov 27, 2005 at 04:01 UTC | |
by Your Mother (Archbishop) on Nov 27, 2005 at 06:19 UTC |