On Wed, Nov 28, 2001 at 01:25:51PM -0500, [EMAIL PROTECTED] wrote:
> $string       = "I want to delete all this spaces, but              this";
> $string       =~ s/\s{1}(?=\w)//g;
> print $string;

Almost, but it doesn't match his description.  Consider a few edge cases:

    "foo  bar"  is changed to "foo bar"

This is due to the fact that you're only using a positive lookahead to
determine if it's a lone space.  You must take into account what's before
the space, as well, to determine if it's a lone space.


    "foo . bar" is changed to "foo .bar"

This is due to the fact that you're doing the lookahead on \w when it should
be on \S, or possibly [^ ].


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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

Reply via email to