in reply to Re: Re: Strip user-defined words with regexp
in thread Strip user-defined words with regexp

I think my original post was a bit too unclear.

I am looking for at most the first two words. So it may be zero, one or two.

I've modified his code to:
my $firstWord = undef; my $secondWord = undef; my $i = 0; while ($message =~ /([A-Za-z0-9]+)/g) { if ($i == 0) { $firstWord = $1; } elsif ($i == 1) { $secondWord = $1; last; } $i++; }
which does exactly what I was looking for. I only tried to do it in one regexp.

Thanks, Marcel