Solved

String: replace "" with "

Posted on 2007-12-07
11
244 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

752 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