On Sep 8, Gary Luther said:

>$line =~ s/\s{2,}(\w+(\s?\W?\w+)*).*?/$1/;

I think you want to use something a bit simpler for the \w+... part:

  $line =~ s/\s{2,}(\S+(?:\s\S+)*).*/$1/;

That gets non-whitespace (\S+) followed by any number of occurrences of a
single whitespace followed by MORE non-whitespace.

The reason the end of your regex breaks is because you use .*? which
matches as few characters as it needs to (which is 0).  Use .* instead.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


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

Reply via email to