Reputation: 477
How do i convert the string;
var s='uploads\product\picture\20Duleek_Lime_Green1.jpg';
into
'uploads/product/picture/20Duleek_Lime_Green1.jpg';
The standard javascript function replace doesnt seem to work.
var s='uploads\product\picture\20Duleek_Lime_Green1.jpg';
strReplace = s.replace('\\', '//');
alert(strReplace);
Upvotes: 2
Views: 1985
Reputation: 207501
There is no replaceAll in JavaScript, use a regular expression with a global flag.
var s='uploads\\product\\picture\\20Duleek_Lime_Green1.jpg';
var strReplace = s.replace(/\\/g, '/');
alert(strReplace);
Upvotes: 4
Reputation: 146302
There is no such function in javascript called replaceAll
You can use regex
with replace()
to achieve what you want to do.
Upvotes: 0