Originally posted by thgiwd: Need help.. How do I replace a single quote ( ' ) with two single quotes ( '' ) ??
I think I know what you're asking. But I'm taking a stab in the dark considering I don't know SPECIFICALLY what is being asked. I am going to guess that you're trying to insert data into a database and that the single quotes in the text is messing you up. You have to write a method which will replace the instances of ' with ''. Here's the algorithm (Specifically for Strings but can be expanded towards other datatypes) 1. Find first index of "SearchString" 2. If first index value does not equal -1 (Continue to step 3, otherwise end search) 3. Use a StringBuffer class to hold the substring from the beginning of the sentence to the index of the first instance of the "SearchString". 4. Append "ReplaceString" to the substring 5. Repeat step 2 starting with original string (plus the length of the searchString). Good luck I'd offer the code to do this but then it would be too easy But if you still have a lot of problems with it, let me know and I'll post it.