我想用php替換兩個詞之間的內容。這兩個詞之間的內容不同,所以我不能使用傳統的str_replace。我想更換兩個詞之間的內容,例如:替換兩個詞之間的內容
I would like to replace **some string of text** between two words
變化:
I would like to replace between two words
你可以看到,我刪除了所有「一些」和「文本」的措辭。我再次無法使用常規的str_replace,因爲兩個單詞之間的文本可能不同。例如,它可能會說:
I would like to replace **some words of text** between two words
變化:
I would like to replace between two words
'$ txt = preg_quote('some string of text'); $ new = preg_replace(「/ $ txt /」,'new text',$ old);'不起作用? –