• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

replace method

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For escaping form input quotes I have been using this:


Can I use something better like an ascii number or please advise?
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean String#replace(java.lang.CharSequence,%20java.lang.CharSequence)? Note that takes a CharSequence as its argument, not a regular expression like the replaceAll method. I think you are passing a regular expression.

I think you can use an ASCII value (well, Unicode) and you should find " in the "basic Latin" page here. You would use "\u1234" or '\u1234' depending whether you want it as a String or a char (or even (char)0x1234!). But you need to check carefully which method you are invoking. I don't think the replace method will allow you to delete the character.
StringBuilder does allow deletions, however.
reply
    Bookmark Topic Watch Topic
  • New Topic