Forums Register Login

How do I replace a single quote ( ' ) with two single quotes ( '' )

+Pie Number of slices to send: Send
Need help..
How do I replace a single quote ( ' ) with two single quotes ( '' ) ??
+Pie Number of slices to send: Send
 

Originally posted by thgiwd:
Need help..
How do I replace a single quote ( ' ) with two single quotes ( '' ) ??


Can you be more specific? Where do you want to do it?
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
hey thanks.. i got it already..
i followed your instructions..
thanks again..
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1760 times.
Similar Threads
How to replace a single quote in a string with two single quotes
String replace function with single quote
Character replacement
apostrophe ( ' ) issue in SQL of Hibernate.
how to insert a value with aphostophy character
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 21:58:35.