Let's take a look at your url:
var url='Page Example';
First let's get rid of both occurences of "
url=url.replace(/"/g,'');
Now remove the first occurence of by feeding the exact string instead of a regular expression to the
.replace
method.
url=url.replace('','');
At this point your url looks like this:
We're getting closer. Let's remove anything in between the >
and the "
by
url=url.replace(/\>(.*)\"/,'"');
which gives us
Almost done - finally let's get rid of "
To make the whole thing a bit more beautiful we can chain all four operations:
var url = 'Page Example';
url = url.replace(/"/g, '').replace('', '').replace(/\>(.*)\"/, '"').replace('"