• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need help..
How do I replace a single quote ( ' ) with two single quotes ( '' ) ??
 
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks.. i got it already..
i followed your instructions..
thanks again..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!