thiebo
thiebo

Reputation: 1435

preg replace in jquery removing dots

I have an URL that looks like this :

http://www.blabla.com/../images/wow.jpg

I would like to remove the double dots and slash and I thought I could do it this way :

var img = IMAGE_PATH + url;
var image = img.replace(/\.{2}\//,'');

But that's not doing anything. Could someone please tell me how I could do this in jquery ?

Thanks

Upvotes: 0

Views: 47

Answers (1)

danielpm
danielpm

Reputation: 125

Try this (no jQuery needed):

var s = 'http://www.blabla.com/../images/wow.jpg'.replace('../','');

Upvotes: 1

Related Questions