-3

how to remove forword slash in javascript?

i am using .replace(///g, '') but not woking.

var testtext = '{\"AnonymousTraveler\": { \"PTC\": \"ADT\" }}';

console.log(testtext);

2
  • 1
    there's no forward slash in your input Commented Mar 17, 2017 at 11:52
  • your code outputs {"AnonymousTraveler": { "PTC": "ADT" }} to the console. Commented Mar 17, 2017 at 11:54

2 Answers 2

1

Front slashes need to be escaped:

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

4 Comments

i am using in replace method '/\//g ' but not working
But like people said above, where is the front slash in your input? I only left this answer here in case you had mistyped your code!
using this code /\\/g working fine. thank you all
Then please accept the answer, and have a good day :)
0

You can do this

var testtext = '{\"AnonymousTraveler\": { \"PTC\": \"ADT\" }}';
testtext = testtext.replace("\\","");
alert(testtext);

1 Comment

using this code /\\/g working fine. thank you all

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.