How do I combine this regex?

 $syb =~ s/(at{3,6})/\U$1/gi;

 $syb =~ s/(aat{2,5})/\U$1/gi;

 $syb =~ s/(aaat{1,4})/\U$1/gi;

 $syb =~ s/(aaaat{0,3})/\U$1/gi;

 $syb =~ s/(aaaaat{0,2})/\U$1/gi;

 $syb =~ s/(a{4,7})/\U$1/gi;

 $syb =~ s/(aaaaaat)/\U$1/gi;

 $syb =~ s/(t{4,7})/\U$1/gi;

Is there a way to get all these regular expressions in one? Is it wrong to use this many regular expressions on one line? the end result should if $ syb aaatcgacgatcgatcaatttcgaaaaaggattttttatgcacgcacggggattaaaa regex should do this aaatcgacgatcgatcaatttcgaaaaaggattttttatgcacgcacggggattaaaa

One problem with my regular expressions is that they match aaaattttas two separate matches and output aaaatttt. I also need to fix this.

I have an ACT and G string stored in $ syb. I want to use any part of the line that contains a set of A, followed by T, just A or just T (T, followed by A), and the title part can be no shorter than 4 and no more than 7

+5
2

. , :

s/((?<!a)a|(?<!a|t)t)((?<!t)\1|t){3,6}(?!\2|t)/\U$&/gi

, :

  • a, a. a t, a t.
    • ((?<!a)a|(?<!a|t)t)
  • 3-6 t's, t
    • ((?<!t)\1|t){3,6}
  • , t.
    • (?!\2|t)/

perl:

$syb = "aaatcgacgatcgatcaatttcgaaaaaggattttttatgcacgcacggggattaaaaactgaaaattttactgaaaaaaaasttttttts";
$syb =~ s/((?<!a)a|(?<!a|t)t)((?<!t)\1|t){3,6}(?!\2|t)/\U$&/gi;
print $syb;

, qtax. :

s/(?:(?<!a)a|(?<!a|t)t)(?:(?<!t)a|t){3,6}(?!(?<=a)a|t)/\U$&/gi

: 5 .

s/(?<!a|t(?=t))(?:a|t(?!a)){3,6}(?:a(?!a)|t)(?!t)/\U$&/gi

s/
# Look behind for a char not an 'a' nor a 't' followed by a 't'
(?<!a|t(?=t))
# Capture 3-6 'a or 't 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$&/gix;
+5

, 7, , . .

:

s/
(?:(?<!a)a|(?<!t|a)t)
(?:(?<=a)a|(?<=a)t|(?<=t)t){3,6}
(?!(?<=a)a|(?<=a)t|(?<=t)t)
/\U$&/gix;

:

s/
# match the first [at] only if not part of a valid sequence
(?:(?<!a)a|(?<!t|a)t)
# only match the allowed transitions: a->a, a->t, t->t
(?:(?<=a)a|(?<=a)t|(?<=t)t){3,6}
# ending can not be a valid transition: negate the above
(?!(?<=a)a|(?<=a)t|(?<=t)t)
/\U$&/gix;

: Jacob, :

s/
# match the first a or t only if it not part of a valid sequence
(?:(?<!a)a|(?<!t|a)t)
# only match the allowed transitions: a->a, a->t, t->t
# (t can follow any of the previous chars, so no need to check it)
(?:(?<=a)a|t){3,6}
# ending can not be a valid transition: negate the above
(?!(?<=a)a|t)
/\U$&/gix;

: :

s/(a+t*|t+)/(length $1 >= 4 && length $1 <= 7)? "\U$1": $1/gie;

PS: OP , , .:)

+3

All Articles