Hi Perlmonks,
I am interested to get all the possible matches from a string using regex. But I have got fewer matches than expected with the perl script g1.pl. I have given the script, the incorrect results and the expected results below. I request perlmonks to provide suggestions how to write the regex to get the correct results.
Here goes the script:
#!/usr/bin/perl use warnings; $seq="TT TATAAT CGCG ATG CAG GAG TGG TAA TGA TAG CC TGA TATAAT CCC A +TG CTA CAT TGA TT"; $seq=~ s/\s//gs; while ($seq=~ /([AG]TG).*?(TAA|TAG|TGA)+?/gs) { my $match=$&; $match=~ s/\s//g; push @matches,$match;} print"\n Matches are:\n\n"; print join ("\n",@matches); print"\n\n"; exit;
I have got the incorrect results like:
C:\Users\Dr Supriyo>cd desktop C:\Users\Dr Supriyo\Desktop>g1.pl Matches are: ATGCAGGAGTGGTAA ATGCTACATTGA
The correct results should be:
Matches are:ATGCAGGAGTGGTAA ATGCAGGAGTGGTAATGA ATGCAGGAGTGGTAATGATAG ATGCAGGAGTGGTAATGATAGCCTGA ATGCTACATTGA
In reply to How does one get all possible matches from regex? by supriyoch_2008
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |