javascript - How to replace character in URL string? -


how can convert following url string

[ipaddress]/folder/\\2014\\5\\5\\abc\\\\cde\\efg\\\\ir12345676765454554\\123456.jpg] 

to

[ipaddress]/folder/2014/5/5/abc/cde/efg/ir12345676765454554/123456.jpg] 

thanks in advance.

it looks want replace every sequence of / , \ single /. here's way :

str = str.replace(/[\/\\]+/g, '/'); 

edit

for new question in don't want replace double / of "http://" (and guess "file://", etc), can :

str = str.replace(/(:?)([\/\\]+)/g, function(_,d,s){ return d ? d+s : '/' }); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -