On Mon, 7 May 2001, Johan Groth wrote:

> I want to strip a variable of all characters including a token, i.e.
> aaa_bbb_ccc_ddd would become bbb_ccc_ddd.  As you can see I want to get rid of
> aaa_. Does anyone know how to acomplish this in Perl?
>
> I've tried:
> $tmp = "aaa_bbb_ccc_ddd"
> $tmp =~ /^\w+_/
> $tmp = $';

This did it for me.

$tmp =~ s/^([A-Za-z]+_)(.*)/\2/;

I think the problem is that \w matches an underscore also, and the regexp
is being greedy as well.  There's probably an even better way to do it
(especially if your strings have foreign characters at it), but that was
what occurred to me off the top of my head.

-- Brett
                                   http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
The price one pays for pursuing any profession, or calling, is an intimate
knowledge of its ugly side.
                -- James Baldwin

Reply via email to