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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:22:30+00:00 2026-05-26T02:22:30+00:00

I need to split an expression with the following strings: ‘with’, ‘select’, ‘from’, ‘where’

  • 0

I need to split an expression with the following strings:

'with', 'select', 'from', 'where'

These will come in the sequence as I wrote. You may assume that each of the words will begin and end with word boundary.

I have done this without any problem. However, a new requirement has arrived. The from clause may contain a whole expression.

That means, the expression may be something like this:

with
   something
select
   something more
from
   with
      aaaa
   select
      bbbb      
   from
      [may be another expression]
   where
      the inner expression ends here
where
   the outer expression ends here

I need not split the inner expression.

Now the question is, is there a standard way to do something like that? Or I need to do it totally on my own manually?

I am not sure if it is important, my application is a C# one.

  • 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-26T02:22:30+00:00Added an answer on May 26, 2026 at 2:22 am

    It looks like your use case is starting to get complicated enough that you might be better off investing the time and refactoring effort to use actual parsing utilities, rather than regular expressions. I’m not a C# programmer, so I can’t help you much with suggestions, but googling for “C# parser libraries” yielded several links that looked promising.

    If you only need up to a fixed level of nesting then I think it technically can be done in regular expressions, but it’s going to get nasty. Probably the simplest approach would be to write an expression for each fixed level of nesting, and match them starting from the top until you get a hit. Ugly, but could work.

    If there’s no limit to the number of nested expressions that could be contained in a top-level expression, then regular expressions are not powerful enough to do this properly, and you’ll need to look at parsing utilities. I would not attempt to write a parser on your own; there’s almost certainly usable libraries that solve most of the tricky problems for you.

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

Sidebar

Related Questions

I need a Regular expression that allows me to split the following string in
I need a regular expression that would split strings like itemXY where X and
I need to split long string into a array with following constrains: The input
I need to a) separate strings from numbers for a selection of cells and
I need a regex expression to split math expression, like: -1*x+2*y to the: -1*x
I need split string by commas and spaces, but ignore the inside quotes, single
I need to split an flv file into chunks of the known size on
I need to split my string input into an array at the commas. Is
I need to split ABAP date like 20091101 --> "01", "november", "2009" The "01"
I need to split a string into chunks of 2,2,3,3 characters and was able

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.