Sim
Sim

Reputation: 39

how to replace ( /" or /') to ( " or ') from the string in javascript

how to replace ( /" or /') to ( " or ') from the string in javascript. I am referring the content inside the braces. Could anyone give me regular expression for that. Thanks

Upvotes: 4

Views: 124

Answers (2)

Guffa
Guffa

Reputation: 700382

You can use one regular expression to replace both:

str = str.replace(/\/(['"])/g, '$1');

Upvotes: 4

Vivin Paliath
Vivin Paliath

Reputation: 95528

string.replace(/\/"/g, "\"").replace(/\/'/g, "'");

Upvotes: 2

Related Questions