Reputation: 3647
When I query twitter feeds, the returned profile url contains backslashs and looks like:
"http:\/\/a0.twimg.com\/profile_images\/2419298032\/image_normal.jpg"
how to remove the backslashes to make it look like:
"http://a0.twimg.com/profile_images/2419298032/image_normal.jpg"
Thanks a lot!
P.S. seems
x=x.replace(/\/gi, "");
doesn't work...
Upvotes: 2
Views: 15936
Reputation: 6836
x = x.replace(/\\/g, '');
You have to use two backslashes to get the \ character. A single backslash is used for control characters such as \r \n etc. Using the double backslash escapes this and gives you what you want.
See also: how can remove backslash in value by jQuery?
Upvotes: 11