views:

28

answers:

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

how to replace all ' and Hello and World to '

result = "'''''''"
+4  A: 
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.

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