Results 1 to 6 of 6
  1. #1
    flywheel's Avatar
    flywheel is offline Member
    Join Date
    Sep 2008
    Posts
    8
    Rep Power
    0

    Question [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

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    racerxadam is offline Member
    Join Date
    Jul 2008
    Posts
    68
    Rep Power
    0

    Default

    Java Code:
    String testString = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    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.

  5. #5
    flywheel's Avatar
    flywheel is offline Member
    Join Date
    Sep 2008
    Posts
    8
    Rep Power
    0

    Default

    Yes - thank you, just what I needed :)

    Many thanks
    flywheel

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. "Jumble" or "Scramble" Program
    By Shadow22202 in forum Java Applets
    Replies: 8
    Last Post: 04-30-2008, 03:42 AM
  2. printing an "E" out of asterisks via strings
    By hokieman07 in forum New To Java
    Replies: 1
    Last Post: 04-08-2008, 05:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •