Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am having a problem with a specific regular expression. The following code recognizes patterns with 6 letters, seemingly ignoring the G at the end of the regular expression.

while($_=~m/(A\w\w[[CGT]TG|AT[ACT]|A[ACG]G]G)/g){ print pos($_),"\t",$1,"\n"; }

The type of pattern I would like it to return could look like this 'AGTCTGG', but if I run that expression on this string, $1 returns 'AGTCTG'.<\p>

Replies are listed 'Best First'.
Re: Regex problem
by Anonymous Monk on Jul 19, 2011 at 14:29 UTC

    Forget this question, I figured out that replacing the outer brackets with parentheses was the appropriate thing to do. Sorry

      Oftentimes YAPE::Regex::Explain is helpful for figuring out just what a regex is doing (as opposed to what you think it's doing).