1
var text = "'Hello'World'''";

how to replace all ' and Hello and World to '

result = "'''''''"

1 Answer 1

4
text.replace(/'|Hello|World/g, "'")

The g is for global, it wont stop at the first match but continue matching as many times as possible.

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

1 Comment

Do you mean that you want to replace ', Hello, World with " instead of '? Change the last argument to "\"".

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.