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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:57:52+00:00 2026-05-26T23:57:52+00:00

I need a regex for finding a substring like from xyzTableName with ( index

  • 0

I need a regex for finding a substring like

from xyzTableName     with   (  index =...  

and

from xyzTableName     (  index =...

If with keyword is not there then it should return a match and if with exists after FROM keyword and before ( then there should be no match. All the other words between from and ( must be ignored.

I have tried with below expression :

    @"\bfrom.*[\s\t\n]+(?<!with)[\s\t\n]([\s\t\n]+index"

And some variants of same. I was able to work it out when there are only normal/single whitespaces. But when I tried with multiple white-spaces and line-breaks, It failed.

  • 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-26T23:57:53+00:00Added an answer on May 26, 2026 at 11:57 pm

    Try this pattern: \bfrom\b(?!.+\bwith\b)[^(]+\(\s*index

    string input = @"from xyzTableName     
    with   (  index =...";
    string pattern = @"\bfrom\b(?!.+\bwith\b)[^(]+\(\s*index";
    bool result = Regex.IsMatch(input, pattern,
                    RegexOptions.Singleline | RegexOptions.IgnoreCase);
    

    The above returns false. Change the input to remove the word “with” and it will return true. By using RegexOptions.Singleline the . metacharacter will match all characters, including newlines (\n).

    Pattern breakdown:

    • \bfrom\b: exactly matches the word “from” and uses word-boundary metacharacters
    • (?!.+\bwith\b): negative look-ahead to check for “with” and the match will fail if it does
    • [^(]+: negative character class to match any character that is not an opening parenthesis, at least once.
    • \(\s*index: match an opening parenthesis (note that it has to be escaped), any whitespace, then the word “index”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help finding or having a RegEx match a MM/YY or MM/YYYY format. My
I need a Regex that will match a java method declaration. I have come
I need a regex that will give me the following results from each example
I need a regex for finding all .h, .c, and .cpp files in a
I need a model for finding all of the regular expressions that would match
I need a regex to match a word that starts with #. I wrote
Here's what I need- RegEx to match a url pattern and rewrite it to
Possible Duplicate: Validating an IP with regex I need the regular expression for finding
I've been struggling with finding a suitable solution :- I need an regex expression
I need regex for asp.net application to match an alphanumeric string at least 6

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.