I wondered what would happen if other letters had square bracketed numbers, I solved that in this way. Seems a regex is the "wrong" solution but it was what struck me first.
use strict; use warnings; my $string='YYSFTVME[13]TDPVN[115]HMVGVISVE[13]GRPGLFWFN[115]ISGGDKN[1 +15]'; my $substring = 'N[115]'; my @chars = $string =~ /(.(?:\[\d+\])?)/gxms; my @positions; foreach my $i (0..$#chars) { push @positions, $i if $chars[$i] eq $substring; } print "Positions: @positions\n";
In reply to Re: How to run index on this one?
by afresh1
in thread How to run index on this one?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |