Solved

Replacing apostrophe within a string

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
javap bin 2 41
tomcat administrtor 12 61
Delete Android all or certain applications data programmatically 9 76
How to convert from xls to xlsx using java 7 56
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

828 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