in reply to Strip user-defined words with regexp

This kinda sounds like homework. You might try typing the following command at your command prompt.
perldoc perlre
Check out the \w match symbol, and ask yourself why you're using all these * in a regex when the problem as stated says +.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re: Re: Strip user-defined words with regexp
by Marcello (Hermit) on Mar 04, 2004 at 14:41 UTC
    I knew somebody was going to say this...

    It's not, I have an application which has to determine by the first two words of a phrase what todo. This phrase can be anything, it might even be only one word. Examples:

    my $message = "test one"; my $message = "test"; my $message = "_$ test..."; my $message = "_$ TEST..1.."; my $message = "_$\nTEST1.\n.1.2.3";
    BTW: \w is not helping me here, since I do not want the underscore character.
      Limbic~Region has almost got it then:
      if ( $message =~ /([a-zA-Z0-9]+)[^a-zA-Z0-9]*([a-zA-Z0-9]*)/ ) { print "$1 $2\n"; }