Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is a tough one. I think this might work:</p> <pre><code>s/((?&lt;!a)a|(?&lt;!a|t)t)((?&lt;!t)\1|t){3,6}(?!\2|t)/\U$&amp;/gi </code></pre> <p>Essentially, what I'm doing is:</p> <ol> <li>Get an <code>a</code> not preceded by an <code>a</code>. Or a <code>t</code> not preceded by an <code>a</code> or <code>t</code>. <ul> <li><code>((?&lt;!a)a|(?&lt;!a|t)t)</code></li> </ul></li> <li>Get 3-6 more of the first match, or <code>t's</code> not preceded by a <code>t</code> <ul> <li><code>((?&lt;!t)\1|t){3,6}</code></li> </ul></li> <li>Make sure it is not followed by the last item in the sequence or a <code>t</code>. <ul> <li><code>(?!\2|t)/</code></li> </ul></li> </ol> <p>And the perl code:</p> <pre><code>$syb = "aaatcgacgatcgatcaatttcgaaaaaggattttttatgcacgcacggggattaaaaactgaaaattttactgaaaaaaaasttttttts"; $syb =~ s/((?&lt;!a)a|(?&lt;!a|t)t)((?&lt;!t)\1|t){3,6}(?!\2|t)/\U$&amp;/gi; print $syb; </code></pre> <hr> <p><strong>Edit</strong> taking a queue from qtax I've removed capturing groups from mine and chars from his:</p> <pre><code>s/(?:(?&lt;!a)a|(?&lt;!a|t)t)(?:(?&lt;!t)a|t){3,6}(?!(?&lt;=a)a|t)/\U$&amp;/gi </code></pre> <p><strong>Edit:</strong> reducing the regex by 5 chars.</p> <pre><code>s/(?&lt;!a|t(?=t))(?:a|t(?!a)){3,6}(?:a(?!a)|t)(?!t)/\U$&amp;/gi </code></pre> <p>with commments </p> <pre><code>s/ # Look behind for a char not an 'a' nor a 't' followed by a 't' (?&lt;!a|t(?=t)) # Capture 3-6 'a's or 't's not followed by 'a's (?:a|t(?!a)){3,6} # Capture an 'a' not followed by an 'a', or a 't' (?:a(?!a)|t) #make sure none of this is followed by a 't'. (?!t) /\U$&amp;/gix; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload