in reply to Find Number in String then Ignore Characters proceeding
If you know that the characters in question will always be uppercase letters (or some other particular character set that doesn't include the next + or -), it's fairly easy: capture the digits and letters that follow a + or -, and use substr to drop the correct number of letters off the beginning:
#!/usr/bin/env perl use Modern::Perl; my $str = ".,a..A,,C..+4ACGTG.,-2TG,,...,a"; $str =~ s/[+-](\d+)(\w+)/substr $2, $1/ge; say $str;
Aaron B.
Available for small or large Perl jobs; see my home node.
|
|---|