On Thursday, September 04, 2003 11:11, Marshall, Stephen wrote:
>
>Got it working this way fror the important line, but theres probably a
slicker way of doing it.
>
>$line =~ s/(\s)+/ /g;
>

This will work, but may leave an extraneous space at the beginning and/or
end of the line.

This text:

"   Test  text       with  lots of   extra spaces   "

would get changed to:

" Test text with lots of extra spaces "

which may not be what you want.

If you want to eliminate any starting or ending space and trim the rest of
it down to single spaces, I would suggest this:

$line =~ s/\s+/ /g;  # the parens you had are not necessary
$line =~ s/^ //;  # removes any space from the beginning of the line
$line =~ s/ $//;  # removes any space from the end of the line

You could probably get fancier on the statements, but I prefer the
simplicity of three separate statements.

HTH,

Alan

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to