Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Re: Strip user-defined words with regexp

by Marcello (Hermit)
on Mar 04, 2004 at 15:03 UTC ( [id://333882]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://333882]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-16 09:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found