• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

String: replace "" with "

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
allelopath
Asked:
allelopath
  • 4
  • 3
  • 2
  • +1
1 Solution
 
cmalakarCommented:
Use replaceAll api
0
 
cmalakarCommented:
string.replaceAll("\"\"", "\"")
0
 
ysnkyCommented:
       String oldStr = "\"C:\\dir1\\dir 2\\dir 3\"";
        String newStr = oldStr.replaceAll("\"", "");
        System.out.print(oldStr + ", " + newStr);
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
ysnkyCommented:
do you mean this;
        String oldStr = "\"\"C:\\dir1\\dir 2\\dir 3\"\"";
        String newStr = oldStr.replaceAll("\"\"", "\"");
        System.out.print(oldStr + ", " + newStr);
0
 
CEHJCommented:
s = s.replaceAll("^\"|\"$","");
0
 
CEHJCommented:
Let's put that in the code window ;-)
s = s.replaceAll("^\"|\"$","");

Open in new window

0
 
CEHJCommented:
:-)
0
 
ysnkyCommented:
:<)

why did not you split the point???
0
 
allelopathAuthor Commented:
because I used CEHJ solution in my code.
0
 
ysnkyCommented:
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
 
allelopathAuthor Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now