Link to home
Start Free TrialLog in
Avatar of sabi97
sabi97

asked on

Replacing apostrophe within a string

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

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vasan_sr
vasan_sr

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

this will work.....
The apostrophe is the char delimiter. You need to use the escape sequence \'.

advert = advert.replace('\'',' ');
Do you get a feeling of deja vu?
Avatar of sabi97

ASKER

Many thanks!