in reply to Find Number in String then Ignore Characters proceeding
$str =~ s/[+-](\d+)(??{".{$1}"})//g;
(Unfortunately, the straightforward attempt $str =~ s/[+-](\d+).{\1}//g; doesn't work.)
See (??{ code }).
Upd: changed (??{"\\w{$1}"}) to (??{".{$1}"}), just in case you need to remove any character, not just alphanumeric.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Find Number in String then Ignore Characters proceeding
by BenPen95 (Initiate) on May 29, 2012 at 21:29 UTC | |
by AnomalousMonk (Archbishop) on May 29, 2012 at 22:51 UTC | |
by Eliya (Vicar) on May 29, 2012 at 23:44 UTC | |
by Eliya (Vicar) on May 29, 2012 at 21:40 UTC |
In Section
Seekers of Perl Wisdom