faressoft
faressoft

Reputation: 19651

how to replace all using regexp (javascript)

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

how to replace all ' and Hello and World to '

result = "'''''''"

Upvotes: 1

Views: 629

Answers (1)

ase
ase

Reputation: 13471

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.

Upvotes: 4

Related Questions