用户脚本替换字符串的所有实例而不是特定实例

User Script replacing all instances of a string instead of specific instances

我一直在学习用户脚本,遇到问题时我一直在弄乱 Joe Simmon's Script。比如说我有一个网页说 'I want to go to a park.' 如果我想用 'the' 替换 'a',它会生成 'I wthent to go to the ptherk.' 而不是 'I want to go to the park.' 有没有更改代码的方法,以便它可以替换 'a' 的实例,它本身就是一个单词,而不是每个字符串中的每个实例。你能解释一下你在做什么吗,这样我就可以学习了。谢谢

该代码有一个例子:'/\bD\b/g' : '[D]',符号\b表示一个单词边界。

您需要 '/\ba\b/g' : 'the''/\bA\b/g' : 'The'