In addition, the inverted character set  [^TAG|TAA|TGA] in the OP regex does not do what I think you think it does. The | (pipe) character has no special meaning in a character set, nor does repetition of a character have significance. The set above is equivalent to the  [^|TAG] set.

My guess about what you originally intended is something along the lines of "not followed by any of the sub-sequences TAG, TAA or TGA". This can be achieved by the negative look-ahead assertion
    (?! TAG | TAA | TGA)
(assuming use of the /x regex modifier).

However, the original expression was  [^TAG|TAA|TGA]? (or its equivalent [^|TAG]?) — note the ? quantifier — meaning "Some character other than  | T A G must be present — or not. Whatever." The ? quantifier makes the whole thing optional either in its character set form or as a negative look-ahead.

On The Other Hand, the OP m// regex used the /g modifier, so the intent may have been something like "step over any three bases other than a TAG, TAA or TGA sub-sequence, if present", which could be achieved by
    (?: (?! TAG | TAA | TGA) ...)?
(again, with the /x modifier), but this is reading a lot into Ekolet's OP.

Update: Furthermore, the  \w+[^ATG]? sub-expression is suspect. I don't understand the intention of this one either if one assumes matching against a string consisting only of A T C G characters or, more generally, only \w characters; in either case, the  \w+ will 'consume' anything that might be matched by the optional  [^ATG]? which is thus rendered effectless.


In reply to Re: Modification of read only values. by AnomalousMonk
in thread Modification of read only values. by Ekolet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.