--- Tony Cook <[EMAIL PROTECTED]> wrote:
> On Mon, 7 May 2001, Johan Groth wrote:
> > I want to strip a variable of all characters including a token,
> > aaa_bbb_ccc_ddd would become bbb_ccc_ddd.
> > . . .
> > I've tried:
> > $tmp = "aaa_bbb_ccc_ddd"
> > $tmp =~ /^\w+_/
> > $tmp = $';
> > but that results in $tmp eq "ddd" instead of "bbb_ccc_ddd".
Another possible solution:
$tmp =~ s/\w+?_//;
this is a substitute with nothing, so it doesn't use $' (which can have
a performance impact). \w represents word characters (including
underscore), but +? means a *minimal* set of one or more. Normally, +
is greedy, grabbing as much of a pattern as it can, which is why your
previous pattern resulted in "ddd" -- is got "aaa_bbb_ccc_" instead of
just "aaa_". This (+?) means to get as *few* characters as can make a
match, which would be "aaa_".
Try it. =o)
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/