supriyoch_2008 has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How does one get all possible matches from regex?
by educated_foo (Vicar) on Dec 10, 2013 at 03:31 UTC | |
by LanX (Saint) on Dec 10, 2013 at 03:38 UTC | |
by educated_foo (Vicar) on Dec 10, 2013 at 04:17 UTC | |
by LanX (Saint) on Dec 10, 2013 at 16:27 UTC | |
|
Re: How does one get all possible matches from regex? (combinations permutations)
by Anonymous Monk on Dec 10, 2013 at 03:58 UTC | |
|
Re: How does one get all possible matches from regex?
by 2teez (Vicar) on Dec 10, 2013 at 06:13 UTC | |
by oiskuu (Hermit) on Dec 10, 2013 at 14:19 UTC |