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

  • Home
  • SEARCH
  • 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 8564977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:19:04+00:00 2026-06-11T17:19:04+00:00

I need to parse Newick format that is useful for trees. It looks like

  • 0

I need to parse Newick format that is useful for trees. It looks like series of brackets, commas and letters denoted nodes:

(A,B,(C,D)E)F

or, for another example:

(,(((,(,)),),))

(,) element means nodes with same parent. For my purpose (to measure a path length between two leafs) I need consequentially to look for such nested elements.

So, my question is how to match different symbols same number of times?

For example, I want to match AB pattern in string:

CCCAAABBACCCABCCAAABBBBBBACCCCCABBBABBCCAABB

Regex should return: ['AABB','AB','AAABBB','AB','AB','AABB']

Every time the number of repetition is different. So A{n}B{n} doesn’t work.

Thanks.

  • 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-11T17:19:05+00:00Added an answer on June 11, 2026 at 5:19 pm

    Your problem is classic example what regular expressions can’t do.

    http://en.wikipedia.org/wiki/Pumping_lemma_for_regular_languages in section “Use of lemma” there is prove that language “a^nb^n” is not regular (so it can’t be recognized by regular expressions).

    Using regular expression you can only create regular expressions for a given maximum n. But expression for large n can take long to evaluate.

    PS. Your problem can be solved using Formal grammars (http://en.wikipedia.org/wiki/Formal_grammar) or Counter automaton (http://en.wikipedia.org/wiki/Counter_automaton).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to parse a line from cmd that looks like this SOME WHITE
I need parse a string inside a parenthesis, which looks like (A, B, C),
I need to parse a C++ stdin input which looks something like this: N
I need to parse a line that is in a similar format as following:
Need to parse a file for lines of data that start with this pattern
i need to parse simple JSON php in my tableview for that i searched
I need to parse some XML that triggers an NSURLConnection. After the parsing finished,
I need to parse a file which is in the following format: General {
I need to parse some information from lines of texts that follow a certain
I need to parse a string which contains custom tags like [link][description][link-url][/link] and I

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.