users
[Top] [All Lists]

Re: [cinjug-users] String problem???

To: "Ray" <andern@xxxxxxxxxxxx>, <users@xxxxxxxxxx>
Subject: Re: [cinjug-users] String problem???
From: "James Carman" <james@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 11 Jun 2003 10:29:25 -0400
Delivered-to: mailing list users@cinjug.org
Mailing-list: contact users-help@cinjug.org; run by ezmlm
References: <010301c33025$5606b830$9865fea9@CodeMasters>
I think you might be getting a bit confused by my usage of a String literal in this case.  The LITERAL that I typed, required the \" (per the Java Language Specification), but the character that shows up when you print it out is ".  Try printing out the input string in my example.  My example DOES work.  Look at what it prints out.  It does exactly what you're asking for.
 
public class StringReplace
{
    public static void main( String[] args )
    {
        String input = "I turned the moon into something I like to call a \"Death Star.\"";
        System.out.println( input );
        System.out.println( StringUtils.replace( input, "\"", "\\\"" ) );
        System.out.println( input.replaceAll( "\"", "\\\\\"" ) );
    }
}
 
----- Original Message -----
From: Ray
Sent: Wednesday, June 11, 2003 10:25 AM
Subject: Re: [cinjug-users] String problem???

Hi folks,
 
Still ALL suggestions do not work. A little more info : the input string is from a string database field that has " in it, and not \". Thanks.
 
Ray
----------------
<Prev in Thread] Current Thread [Next in Thread>