Solved

Replacing apostrophe within a string

Posted on 2002-06-28
5
270 Views
Last Modified: 2010-03-31
Hi,

I'm trying to replace any apostrophes within a string, using :

advert = advert.replace(''', ' ');

but get an 'Unclosed string literal' error.

How do I get around this?

Cheers

sabi97

0
Comment
Question by:sabi97
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 7115992
Escape the first thus:
advert = advert.replace('\'', ' ');

0
 
LVL 2

Expert Comment

by:vasan_sr
ID: 7116161
advert = advert.replace('\'', ' ');

this will work.....
0
 
LVL 3

Expert Comment

by:yasser_helmy
ID: 7121783
The apostrophe is the char delimiter. You need to use the escape sequence \'.

advert = advert.replace('\'',' ');
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 7121811
Do you get a feeling of deja vu?
0
 

Author Comment

by:sabi97
ID: 7121871
Many thanks!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now