lairel has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to grasp the regular expressions and various uses for them. I am working on a problem where I am given a string of letters and have to use a regular expression to find the sequences that starts with ATG and ends with TAG, TAA, or TGA. I am having trouble figuring out the regular expression that would search for each of these endings in a single expression. Here is what I have so far
#!/usr/bin/perl use strict; use warnings; use diagnostics; #insert sequence my $seq = 'AATGGTTTCTCCCATCTCTCCATCGGCATAAAAATACAGAATGATCTAACGAA'; #find codons while ($seq =~ m/ATG(.*)(TAG|TAA|TGA)/g){ #print codons print $1, "\n"; }
but I am not getting the correct output, instead getting that the $1 is unspecified. Any suggestions? I would really like to understand how this sort of regular expression works. Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular expressions
by stevieb (Canon) on Oct 26, 2015 at 18:51 UTC | |
by lairel (Novice) on Oct 27, 2015 at 16:38 UTC | |
by stevieb (Canon) on Oct 27, 2015 at 17:02 UTC | |
|
Re: Regular expressions
by kennethk (Abbot) on Oct 26, 2015 at 19:42 UTC | |
by Laurent_R (Canon) on Oct 26, 2015 at 20:06 UTC | |
by Athanasius (Archbishop) on Oct 27, 2015 at 06:27 UTC | |
by AnomalousMonk (Archbishop) on Oct 27, 2015 at 07:27 UTC | |
|
Re: Regular expressions
by Discipulus (Canon) on Oct 27, 2015 at 07:58 UTC | |
|
Re: Regular expressions
by ww (Archbishop) on Oct 28, 2015 at 18:13 UTC |