aspose file tools
The moose likes Beginning Java and the fly likes String replace function with single quote Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "String replace function with single quote" Watch "String replace function with single quote" New topic
Author

String replace function with single quote

Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
My problem is I understand how a replace function works with the Strings. My problem is I have string with single quotes ', and I need to change them to two single quotes '', because I need to insert them into a database. How can I do this using the replace function.
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
I think you can try to use the escape character like so "\'".
Let me know if this works
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
The replace function in String only works with single characters. You can use a better replace function such as the one that I've written in my StringHelper:
http://ostermiller.org/utils/StringHelper.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String replace function with single quote
 
Similar Threads
How can i remove single quote from a string
How to replace a single quote in a string with two single quotes
embedding javascript function in href
Problem escaping single quotes using regex with replaceAll()
How do I replace a single quote ( ' ) with two single quotes ( '' )