Results 1 to 6 of 6
- 09-28-2008, 07:18 AM #1
[SOLVED] Handling strings including " character
Hello
I'm creating a small textmode program where I need to handle strings (String). Some of the strings will have to include the " character - an example : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
I have tried inserting doubles (An " for every " in the string) - but that does not seem to help - how on earth do I handle this ??
Many Thanks
flywheel
- 09-28-2008, 07:47 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You need to handle it as a escapes sequence. Replace " with \" in your application.
- 09-28-2008, 09:04 AM #3
Member
- Join Date
- Jul 2008
- Posts
- 68
- Rep Power
- 0
Java Code:String testString = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
- 09-28-2008, 10:01 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
In run time you have to replace them. It's possible to do in different ways.
Since Java 1.4 you can use replaceAll(original_string, replacing_string) to replace all occurrence of a string.
- 09-29-2008, 12:17 AM #5
Yes - thank you, just what I needed :)
Many thanks
flywheel
- 09-29-2008, 03:45 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
"Jumble" or "Scramble" Program
By Shadow22202 in forum Java AppletsReplies: 8Last Post: 04-30-2008, 03:42 AM -
printing an "E" out of asterisks via strings
By hokieman07 in forum New To JavaReplies: 1Last Post: 04-08-2008, 05:45 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks