String Replace single quote with \'

J

jacky

Any way to replace a String with single quote with \' ?
e.g. June's Menu --> June\'s Menu

Thanks
June
 
V

VisionSet

jacky said:
Any way to replace a String with single quote with \' ?
e.g. June's Menu --> June\'s Menu

June\\'s Menu

Single quote is irrelevent, unless I'm misunderstanding you.
 
J

jAnO!

jacky said:
Any way to replace a String with single quote with \' ?
e.g. June's Menu --> June\'s Menu

Thanks
June

check API.

Class String, method replaceAll
 
A

Alan Moore

Any way to replace a String with single quote with \' ?
e.g. June's Menu --> June\'s Menu

Thanks
June

str = str.replaceAll("'", "\\\\'");

The backslash serves as an escape character both for Java String
literals and for the replacement string, so you have to use four of
them to make one appear in the output.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top