Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

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

0
sabi97
Asked:
sabi97
1 Solution
 
CEHJCommented:
Escape the first thus:
advert = advert.replace('\'', ' ');

0
 
vasan_srCommented:
advert = advert.replace('\'', ' ');

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

advert = advert.replace('\'',' ');
0
 
CEHJCommented:
Do you get a feeling of deja vu?
0
 
sabi97Author Commented:
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now