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

The Archive Base Latest Questions

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

How will I be able to look for kewords that are not inside a

  • 0

How will I be able to look for kewords that are not inside a string.

For example if I have the text:

Hello this text is an example.

bla bla bla “this text is inside a string”

“random string” more text bla bla bla “foo”

I will like to be able to match all the words text that are not inside " ". In other I will like to match:

enter image description here

note I do not want to match the text that is highlighted on red because it is inside a string


Possible solution:

I been working on it and this is what I have so far:

(?s)((?<q>")|text)(?(q).*?"|)

note that regex uses the if statement as: (?(predicate) true alternative|false alternative)

so the regex will read:

find ” or text. If you find ” then continue selecting until you find ” again (.*?”) if you find text then do nothing…

when I run that regex I match the whole string though. I am asking this question for purposes of learning. I know I can remove all strings then look for what I need.

  • 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-08T07:23:45+00:00Added an answer on June 8, 2026 at 7:23 am

    Here is one answer:

    (?<=^([^"]|"[^"]*")*)text
    

    This means:

    (?<=       # preceded by...
    ^          # the start of the string, then
    ([^"]      # either not a quote character
    |"[^"]*"   # or a full string
    )*         # as many times as you want
    )
    text       # then the text
    

    You can easily extend this to handle strings containing escapes as well.

    In C# code:

    Regex.Match("bla bla bla \"this text is inside a string\"",
                "(?<=^([^\"]|\"[^\"]*\")*)text", RegexOptions.ExplicitCapture);
    

    Added from comment discussion – extended version (match on a per-line basis and handle escapes). Use RegexOptions.Multiline for this:

    (?<=^([^"\r\n]|"([^"\\\r\n]|\\.)*")*)text
    

    In a C# string this looks like:

    "(?<=^([^\"\r\n]|\"([^\"\\\\\r\n]|\\\\.)*\")*)text"
    

    Since you now want to use ** instead of " here is a version for that:

    (?<=^([^*\r\n]|\*(?!\*)|\*\*([^*\\\r\n]|\\.|\*(?!\*))*\*\*)*)text
    

    Explanation:

    (?<=       # preceded by
    ^          # start of line
     (         # either
     [^*\r\n]| #  not a star or line break
     \*(?!\*)| #  or a single star (star not followed by another star)
      \*\*     #  or 2 stars, followed by...
       ([^*\\\r\n] # either: not a star or a backslash or a linebreak
       |\\.        # or an escaped char
       |\*(?!\*)   # or a single star
       )*          # as many times as you want
      \*\*     # ended with 2 stars
     )*        # as many times as you want
    )
    text      # then the text
    

    Since this version doesn’t contain " characters it’s cleaner to use a literal string:

    @"(?<=^([^*\r\n]|\*(?!\*)|\*\*([^*\\\r\n]|\\.|\*(?!\*))*\*\*)*)text"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need that my applicatiob will be able to get mail... this is c#
I'm hoping someone have encountered this problem before and will be able to help
How can I edit this foreach loop so that I will be able to
I have writted a Java program that will be able to add customers to
This is something I will be able to do, but I'm curious to hear
I need to have a DateTimePicker which will be able to select the Time
I was looking at creating a common control that I will be able to
If you have looked at Pinterest you will know they have a bookmarklet that
I have a game application that I will be running in a web browser
I'm developing a full-screen web app for an iPad that will have a series

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.