some text and some text too bad,
some too bad again some bad
and other words bad, it is 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;
請幫
雖然正則表達式的專家可以創造奇蹟,在最後總要有人理解和維護這樣的代碼。 –