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
Post a Comment