A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Problems manipulating string
Joined: Dec 14, 2005
Dec 21, 2005 07:59:00
Hello to everyone. I have a little problem manipulating a
The initial string is as follows:
What I need to do is retrieve a string does not contain the ' in the beginning and the end. I tried the following unsuccessfully:
line = (line.replace('\'', ' ')).trim();
line = line.substring(0, line.length() - 1);
line = line.replace(' ', '\'');
I obtain the following:
); (spaces are still left behind without the ' after the \).
I do not if it helps but this line will eventually be used in an html document.
Thank you for your help
[ EJFH: Turn off smilies ]
[ December 21, 2005: Message edited by: Ernest Friedman-Hill ]
author and iconoclast
Joined: Jul 08, 2003
Dec 21, 2005 08:36:00
[Jess in Action]
Joined: Dec 20, 2004
Dec 21, 2005 08:49:00
How about using something like the following (no, I didn't actually
it). It seems like the replacing is just making things overly complicated.
line = line.trim(); line = line.substring(1, line.length() - 1);
Joined: Mar 27, 2003
Dec 21, 2005 08:51:00
I assume you are trying to convert the Java String containing:
into a String containing this:
If so, you could always try substring() between the first occurrence of ' (using indexOf()) and the last occurrence of ' (using lastIndexOf()).
If I've misunderstood, please set the question in context...
[ December 21, 2005: Message edited by: Charles Lyons ]
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 /
subject: Problems manipulating string
Returning arrayList and Final line value alone getting printed in jsp
Applet Server communication for SAX Parser Delaying the process
save a xml file using java
Modify Newline character in java
While replacing char of soap response then it throws error
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015