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 7195791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:39:02+00:00 2026-05-28T20:39:02+00:00

The input can be either 1. or 2. or a combination of both. Sequential

  • 0

The input can be either 1. or 2. or a combination of both.

  1. Sequential
    ...
    startLoop
      setSomething
    endLoop

    startLoop
      setSomething
    endLoop
    ...

The regex I use for this is (startLoop.+?endLoop)+? to get each loop block as my matcher group. This works fine for the sequential case where I access setSomething each time and alter it.

  1. Nested
    ...
    startLoop
      setSomething1.1
      startLoop
        setSomething2.1
        startLoop
          setSomething3
        endLoop
        setSomething2.2
      endLoop
      setSomething1.2
    endLoop
    ...

I wrote something like (startLoop.+?startLoop)+? but that only lets me access setSomething1.1

I’m not able to come up with a regex that lets me access setSomething no matter what type of loop structure the input has.

Appreciate your help.

  • 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-05-28T20:39:02+00:00Added an answer on May 28, 2026 at 8:39 pm

    I don’t think it is possible to capture what you’re describing with the help of regular expressions. Regular expressions can only capture regular languages whereas what you described for the nested loop situation is quite similar to a context-free language. According to the Chomsky hierarchy, regular languages form a strict subset of context-free languages and, therefore, cannot capture all context-free languages.

    CFGs vs Regular Expressions

    Context-free grammars are strictly more powerful than regular expressions.

  2. Any language that can be generated using regular expressions can be generated by a context-free grammar.
  3. There are languages that can be generated by a context-free grammar that cannot be generated by any regular expression.
  4. Reference: http://www.cs.rochester.edu/~nelson/courses/csc_173/grammars/cfg.html

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

Sidebar

Related Questions

I have a function whose input argument can either be an element or a
How can I send keyboard input messages to either the currently selected window or
How can we check if the input number is either positive or negative in
This question is a combination of regex practice and unit testing practice. Regex part
So the issue is the user can either give input that is one int,
My understanding is that one can use either of the two methods for case-insensitive
i have a form where user can either input email ids like someone@somewhere.com,anyone@anywhere.com OR
I have an input text which can be either: URL: http://www.cnn.com Cookie: xxx; yyy
How do I limit the types of HTML that a user can input into
On a website if I have a form where the user can input some

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.