Solved

String: replace "" with "

Posted on 2007-12-07
11
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

617 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