Solved

String: replace "" with "

Posted on 2007-12-07
11
224 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to parse custom JSON to POJO java 4 55
Passing list of object to Oracle Database Procedure 3 59
windows explorer path to command prompt 5 29
java stored proc example 9 20
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…
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…
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:
The viewer will learn how to implement Singleton Design Pattern in Java.

911 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