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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:33:49+00:00 2026-06-11T05:33:49+00:00

My file contains some lines such as This is a string. = This is

  • 0

My file contains some lines such as

"This is a string." = "This is a string's content."
" Another \" example \"" = " New example."
"My string
can have several lines." = "My string can have several lines."

I need to extract the substring :

This is a string.
This is a string's content.
 Another \" example \"
 New example.
My string
can have several lines.
My string can have several lines.

Here’s my code:

String regex = "\".*?\"\\s*?=\\s*?\".*?\"";
Pattern pattern = Pattern.compile(regex,Pattern.DOTALL);
Matcher matcher = pattern.matcher(file);

For the moment, I can get the pair of left and right part of “=”. But when my substring contains ” \” “, my regex dosen’t do the right job.

Can anyone help me write the correct regex please ? I tried \”^[\\”] instead of \”, but it didn’t work..

Thanks advance.

  • 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-11T05:33:51+00:00Added an answer on June 11, 2026 at 5:33 am
    List<String> matchList = new ArrayList<String>();
    Pattern regex = Pattern.compile(
        "\"          # Match a quote\n" +
        "(           # Capture in group number 1:\n" +
        " (?:        # Match either...\n" +
        "  \\\\.     # an escaped character\n" +
        " |          # or\n" +
        "  [^\"\\\\] # any character except quotes or backslashes\n" +
        " )*         # Repeat as needed\n" +
        ")           # End of capturing group\n" +
        "\"          # Match a quote", 
        Pattern.COMMENTS);
    Matcher regexMatcher = regex.matcher(subjectString);
    while (regexMatcher.find()) {
        matchList.add(regexMatcher.group(1));
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one file (for example: test.txt), this file contains some lines and for
I have an XML Template file. This file contains a header and some predefined
I have a huge file of code with many lines like this: Enterprise::TextMessageBox::Show(String::Format(SВъзникнал е
I have a data file that is several million lines long, and contains information
I have a file in UTF-8, where some lines contain the U+2028 Line Separator
I have a text file that contains some strings separated by ,. Strings are
So what I have is a MS Word docx file that contains some data
i have a file which contains a lot of update query and some other
I have a .txt file that contains a list of names and some numbers.
i have a directory called testDir and it contains 1000 file, some of them

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.