in reply to Re^4: Proper usage of rindex function?
in thread Proper usage of rindex function?
A regex solution might be fairly efficient, since you are looking for a simple word boundary. But I'd suggest using tr+index if making a copy of the $str is not a problem. That might be the fastest as well.
# sub via_rx { $_[0] =~ /.*\b(?<=[ATCG])/s; $+[0] } sub via_rx { $_[0] =~ /.*\w\b/s; $+[0] } sub via_tr { 1+rindex(($_[0] =~ tr/ATCG/X/r), 'X') }
|
|---|