Solved

Replacing apostrophe within a string

Posted on 2002-06-28
5
278 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
network + 7 80
ArrayIndexOutOfBoundException 9 66
how to add new optional parameter to JSP 1 26
Why my table column Id is not passed to java object? 4 21
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

914 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

14 Experts available now in Live!

Get 1:1 Help Now