Home>

I want to use javascript replace to replace only arbitrary characters that come to the end of a sentence.
I was able to replace yen → yen (tax included) in the description below, but I don't want to replace the circle part that is yen + tax ~.

Example)
110 yen → 110 yen (tax included)
100 yen + tax ~ → Do not replace

  • Answer # 1

    strObj.replace (/ Yen (?! \ + Tax)/g