Solved

String: replace "" with "

Posted on 2007-12-07
11
216 Views
Last Modified: 2010-03-30
I have a String that llooks like this;
""C:\dir1\dir 2\dir 3""
I need to replace the pairs of quotes with just one quote, something like this:
replace ("\"\"", "\"");
(but that doesn't work because the arguments to replace are not String)
How do I do this?
0
Comment
Question by:allelopath
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 23

Expert Comment

by:cmalakar
ID: 20426852
Use replaceAll api
0
 
LVL 23

Expert Comment

by:cmalakar
ID: 20426862
string.replaceAll("\"\"", "\"")
0
 
LVL 9

Expert Comment

by:ysnky
ID: 20426879
       String oldStr = "\"C:\\dir1\\dir 2\\dir 3\"";
        String newStr = oldStr.replaceAll("\"", "");
        System.out.print(oldStr + ", " + newStr);
0
 
LVL 9

Expert Comment

by:ysnky
ID: 20426888
do you mean this;
        String oldStr = "\"\"C:\\dir1\\dir 2\\dir 3\"\"";
        String newStr = oldStr.replaceAll("\"\"", "\"");
        System.out.print(oldStr + ", " + newStr);
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20426900
s = s.replaceAll("^\"|\"$","");
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 20426906
Let's put that in the code window ;-)
s = s.replaceAll("^\"|\"$","");

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20426969
:-)
0
 
LVL 9

Expert Comment

by:ysnky
ID: 20426982
:<)

why did not you split the point???
0
 
LVL 1

Author Comment

by:allelopath
ID: 20427001
because I used CEHJ solution in my code.
0
 
LVL 9

Expert Comment

by:ysnky
ID: 20427030
it is not a satisfied explanation not to split the point.
btw you can not use multiple solution in your code, so you will never split.
0
 
LVL 1

Author Comment

by:allelopath
ID: 20458081
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 48
Receive file in Servlet 1 36
Java Message handling in Service Layer 3 37
ArrayIndexOutOfBoundException 9 35
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now