some text and some text too bad,
some too bad again some bad
and other words bad, it is too bad
我正在尝试将所有单词“bad”替换为“good”,但也有例外:
如果单词“too”在“bad”之前,“bad”不应该改为“good”,“too”和“bad”之间可以有一个或微小的空格,甚至html空格“”
所以在正则表达式操作文本之后应该是
some text and some text too bad,
some too bad again some good
and other words good, it is too bad
尝试过这样的事情,但它不能正常工作。
$text ~= s/(too(\s+|\s* \s*))bad/good/ig;
请帮忙