?
Solved

Replacing apostrophe within a string

Posted on 2002-06-28
5
Medium Priority
?
311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

741 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