2

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...

1 Answer 1

11

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.