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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:42:24+00:00 2026-05-14T16:42:24+00:00

//This source is a line read from a file String src = 23570006,music,**,wu(),1,exam,\Monday9,10(H2-301)\,1-10,score,; //This

  • 0
    //This source is a line read from a file 
    String src = "23570006,music,**,wu(),1,exam,\"Monday9,10(H2-301)\",1-10,score,";

    //This sohuld be from a matcher.group() when Pattern.compile("\".*?\"")
    String group = "\"Monday9,10(H2-301)\"";

    src = src.replaceAll("\"", "");
    group = group.replaceAll("\"", "");

    String replacement = group.replaceAll(",", "#@");
    System.out.println(src.contains(group));
    src = src.replaceAll(group, replacement);
    System.out.println(group);
    System.out.println(replacement);
    System.out.println(src);

I’m trying to replace the "," between \"s so I can use String.split() latter.

But the above just not working , the result is:

true  
Monday9,10(H2-301)  
Monday9#@10(H2-301)  
23570006,music,**,wu(),1,exam,Monday9,10(H2-301),1-10,score,

but when I change the src string to

 String src = "123\"9,10\"123";  
 String group = "\"9,10\"";

It works well

true  
9,10  
9#@10  
1239#@10123

What’s the matter with the string???

  • 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-14T16:42:25+00:00Added an answer on May 14, 2026 at 4:42 pm

    ( and ) are regex metacharacter; they need to be escaped if you want to match it literally.

    String group = "\"Monday9,10\\(H2-301\\)\"";
                                ^        ^
    

    The reason why you need two slashes is that because \ in a string literal is itself an escape character, so "\\" is a string of length 1 containing a slash.

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

Sidebar

Related Questions

I want to be able to read from an unsorted source text file (one
I have this source code from 2001 that I would like to compile. It
I need to read a XML file returned from a web service. I was
Working on a problem where I have to read data from a file into
This code is copy from http://code.google.com/p/closure-library/source/browse/trunk/closure/bin/build/source.py The Source class's __str __method referred self._path Is
I guess this will sound crazy, but I am reading from a file, and
I want to read from the text file which is placed in res/raw/text i
Consider this source: public partial class FormTest : Form { private Test test {
like this (source: photoshopessentials.com )
i'm studying this source base . Basically this is an Anim server client for

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.