Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:15:08+00:00 2026-06-15T07:15:08+00:00

I have a little trouble with a regular expression. I have the following one:

  • 0

I have a little trouble with a regular expression. I have the following one: (A|C|G|T){3} which gives every permutation of three letters from A,B,C,D but now I want to exclude three specific patterns: "TAG", "TAA" and "TGA" . Tried with [^], but it is not yielding expected results. Same goes using look-around(look ahead and look-behind).

What I am trying to achieve is to find all sub-strings who start with “ATG”, end with either “TAG”, “TAA” or “TGA” and in the middle it should have triples of A,C,G or T.

Thanks for the help!

Here is what I have done so far:

(ATG)((((A|C|G|T)){3})[^TAG][^TAA][^TGA])*(TAG|TAA|TGA)

(ATG)((?!TAG)(?!TAA)(?!TGA)(((A|C|G|T)){3})*)(TAG|TAA|TGA)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:15:09+00:00Added an answer on June 15, 2026 at 7:15 am

    If I understand correctly:

    1) Start with ATG

    2) A number of triplets, except ‘TAG’, ‘TAA’, and ‘TGA’

    3) One of the triplets ‘TAG’, ‘TAA’, or ‘TGA’

    This should work:

    /
       (ATG)                       # Step 1
       ((?!TAG|TAA|TGA)[ACGT]{3})+ # Step 2
       (TAG|TAA|TGA)               # Step 3
    /x
    

    The difference from you second idea it to move the negative look-ahead inside the quantifier to get ‘a number of triplet’ step ensuring that neither of the triplets are one of the exceptions

    This solution does not assume any commonality between the elements in step 2 and step 3. A simpler, but in your case equivalent, formulations would be:

    1) Match ‘ATG’

    2) Match a number of triplets

    3) … until you match ‘TAG’, ‘TAA’, ‘TGA’.

    To do this you just need to make the quantifier in step 2 non-greedy, as this would test is Step 3 matches before trying if step 2 matched again.

    Then the solution would look like:

    / (ATG) ([ACGT]{3})*? (TAG|TAA|TGA) /x
    

    An alternative interpretation might be:

    1) Start with ATG

    2) A number of triplets

    3) One of the triplets ‘TAG’, ‘TAA’, ‘TGA’

    4) The substring found in step 2 must not contain the substrings ‘TAG’, ‘TAA’, ‘TGA’.

    In this case I would solve it using two regular expressions. On implementing step 1-3 and one for the test in step 4:

     $sequence =~ /(ATG)([ACGT]{3})(TAG|TAA|TGA)/ and $2 !~ /TAG|TAA|TGA/;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I a having a little trouble with vector or array operations. I have three
I have little trouble understanding why variables aren't working properly in the following code.
I have posted my code below, but essentially I'm having a little trouble. I
I have a little script here which uses DOMDocument to get my data from
i have little trouble with updating database by ajax , but i couldnt make
I wrote few custom view helpers but I have a little trouble using them.
I have having a little trouble with my project. I have a textfield which
I want to try out vim, but have a little trouble with the config
Hay, I'm having a little trouble. I have the following domain over at easily.co.uk
I have a little trouble deciding which way to go for while designing the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.