You are right john, I did't read the whole question when I replied. Now
everyone out there please don't spank me.
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Johnson Winfrey
Sent: Thursday, September 20, 2001 2:37 PM
To: [EMAIL PROTECTED]
Subject: Re: replacing apostrophes
you need to escape the apostrophe... that way the compiler knows the middle
apostrophe is the character and isn't the ending apostrophe. the following
code
works...
char myChar = '\'';
char myUnderscore = '_';
String myString = "Y'all come back now.";
System.out.println(myString);
System.out.println(myString.replace(myChar,myUnderscore ));
good luck,
-john
Barbara Johnson <[EMAIL PROTECTED]> on 09/20/2001 02:54:19 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: 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