> String str = "aaabbbccc";
> String str2 = new String(str.replace('a','b'));
don't use new String()... just set
String str2 = str.replace('a','b');
-john
Tom & Sharon Kochanowicz <[EMAIL PROTECTED]> on 09/20/2001 03:00:48 PM
Please respond to "A mailing list for discussion about Sun Microsystem's Java
Servlet API Technology." <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Winfrey Y Johnson/IT/VANCPOWER)
Subject: Re: replacing apostrophes
Strings are immutable, you need to create a new String, for example:
String str = "aaabbbccc";
String str2 = new String(str.replace('a','b'));
T. Kochanowicz
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Barbara Johnson
Sent: Thursday, September 20, 2001 1:54 PM
To: [EMAIL PROTECTED]
Subject: replacing apostrophes
Hello All,
I need to replace apostrophes from in the text a user puts in a form input
textboxe before the text goes into the mysql database. If apostrophes go
into the database it gets corrupted.
I tried the "replace" function and can use it to replace a letter but am
having trouble with the syntax to use
to tell it to replace an apostrophe because the function says to use single
quotes around the variables that you are replacing.
This works:
String str = "aaabbbccc";
out.println (str.replace('a','b'));
This doesn't work:
String str = "aaabbbccc";
out.println (str.replace(''',''''));
I tried subsituting the outer single quotes with double quotes. That doesn't
work either.
Any suggestions would be appreciated.
Thanks,
Barbara Johnson
Instructional Applications Programmer
[EMAIL PROTECTED]
Northeastern Ohio Universities College of Medicine
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html