Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > String Replace single quote with \'

Reply
Thread Tools

String Replace single quote with \'

 
 
jacky
Guest
Posts: n/a
 
      06-14-2004
Any way to replace a String with single quote with \' ?
e.g. June's Menu --> June\'s Menu

Thanks
June
 
Reply With Quote
 
 
 
 
Thomas Kellerer
Guest
Posts: n/a
 
      06-14-2004
<http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.la ng.String)>


On 14.06.2004 11:18 jacky wrote:

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

 
Reply With Quote
 
 
 
 
VisionSet
Guest
Posts: n/a
 
      06-14-2004


"jacky" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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.

--
Mike W


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-14-2004
On Mon, 14 Jun 2004 12:19:21 +0100, "VisionSet" <(E-Mail Removed)>
wrote or quoted :

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


you don't have to except inside single char literals.

To change " to \" see http://mindprod.com/quoter.html

Tell it you want to convert text to Java string literals.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
jAnO!
Guest
Posts: n/a
 
      06-14-2004

"jacky" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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


 
Reply With Quote
 
Alan Moore
Guest
Posts: n/a
 
      06-15-2004
On 14 Jun 2004 02:18:51 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (jacky) wrote:

>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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with single-quote and double-quote when using subprocess. Evan Python 3 11-04-2008 12:24 PM
problem with quote and single-quote when using "subprocess" Evan Python 1 11-04-2008 12:08 AM
How to handling string contains single quote and double quote vikrant Perl Misc 8 05-17-2007 04:37 PM
Datagrid on load; replace all double single quote to single quote to display to user Eric Layman ASP .Net 3 04-14-2007 07:16 AM
Single Quote Versus Double Quote In A href link knee-dragger@hotmail.com HTML 3 06-13-2006 12:42 AM



Advertisments