Solved

String: replace "" with "

Posted on 2007-12-07
11
237 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
javap bin 2 40
SHA2 certs for IIS AND Java? 2 113
ejb on wildfly 5 30
running on tomcat not jboss eap 7.0 3 17
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

789 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