我需要用自己的几个字取代。 例如
案文案文有点改动。
Need to be replaced by <b>dog</b>
or <b>cat</b>
or <b>mouse</b>
if match.
I needed to replace it once . If it find word dog means to replace the only dog in <b>dog</ b>
. And nothing more. Even if cat or mouse will be the text.
我有法典。
var str = "dog text cat text mouse",
reg = /dog|cat|mouse/;
str = str.replace(reg, <b>dog</b> ).
Sorry, this only replace any of matched with <b>dog</b>
.
Help me , please.