javascript - JS multiple replace -
i have problem.
i don't know how explain it, i'll give example:
i want replace =)
bla1
, , want replace =))
bla2
.
but happens =))
becomes bla1)
what can do?
thanks lot, , sorry english
edit: can't replace =))
first. have more signs this. (>:),:((,:)) , more...). of them in array , use loop replace of them. it'll complicated change of them. array big
first replace more specialized one.
- replace =)) bla2
- replace =) bla1
example
var text = "this =)) =) demo =)) =) =)) text"; text = text.replace(/=\)\)/g, "bla2"); // =)) text = text.replace(/=\)/g, "bla1"); // =) // text = bla2 bla1 demo bla2 bla1 bla2 text
failed example
var text = "this =)) =) demo =)) =) =)) text :))"; text = text.replace(/=\)/g, "bla1"); // =) text = text.replace(/=\)\)/g, "bla2"); // =)) // text = bla1) bla1 demo bla1) bla1 bla1) text
Comments
Post a Comment