Solved

Replacing apostrophe within a string

Posted on 2002-06-28
5
297 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 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
How to get all the API from website? 11 159
How to execute a Python program and gather return output in Java 2 61
jboss 7.1 start up error 1 82
ArrayList Adding/settign data 3 36
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

737 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