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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:20:47+00:00 2026-06-09T06:20:47+00:00

Suppose I have the following text in a text file First Text Some Text

  • 0

Suppose I have the following text in a text file

First Text

“Some Text”

“124arandom txt that should not be parsed!@

“124 Some Text”

“어떤 글”

this text a”s well should not be parsed

I would like to retrieve Some Text, 124 Some Text and 어떤 글 as matched strings. The text is read line by line. Catch is, it has to match foreign languages as well if it is inside quotes.

Update:
I found out something weird. I was trying some random stuff and found out that:

string s = "어떤 글"
Regex regex = new Regex("[^\"]*");
MatchCollection matches = regex.Matches(s);

matches have a count = 10 and have generated some empty items inside (The parsed text is in index 2). This might’ve been why I kept getting empty string when I was just doing Regex.Replace. Why is this happening?

  • 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-09T06:20:48+00:00Added an answer on June 9, 2026 at 6:20 am

    If you read the text line by line, then the regex

    "[^"]*"
    

    will find all quoted strings, unless those may contain escaped quotes like "a 2\" by 4\" board".

    To match those correctly, you need

    "(?:\\.|[^"\\])*"
    

    If you don’t want the quotes to become part of the match, use lookaround assertions:

    (?<=")[^"]*(?=")
    (?<=")(?:\\.|[^"\\])*(?=")
    

    These regexes, as C# regexes, can be created like this:

    Regex regex1 = new Regex(@"(?<="")[^\""]*(?="")");
    Regex regex2 = new Regex(@"(?<="")(?:\\.|[^""\\])*(?="")");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following directory structure in Vim's NERDTree: /some/folder/ |-apples.txt |-bananas.txt |-
I have an ActionMailer controller that's supposed to send this file: /user_mailer/welcome_email.text.erb This is
suppose i have the following in a text file (or dired buffer) open in
Suppose I have a plain text file with the following data: DataSetOne <br />
So suppose I have a text file of the following contents: Hello what is
Suppose I have a .csv file with the following content: text, with commas,another text,123,text,5;
suppose I have following test/ Main.py test/one/ One.py test1.txt test/two/ Two.py test2.txt What I
Possible Duplicate: Are file descriptors shared when fork()ing? Suppose I have following code in
Suppose I have the following list: ID3_tag = ['Title','Artist','Album','Track'] And I have a file
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name

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.