我想更換更換匹配不區分大小寫的假設組合:正則表達式與匹配+插件
text St<font color="red">miX</font>x and some more <font color="red>mIx</font> text
代碼:
$string = "text StmiXx and some more mIxx text";
$pattern = "/mix/i";
$replacement = "<font color=\"red\">match</font>";
echo preg_replace($pattern, $replacement, $string);
如何
text StmiXx and some more mIxx text
正則表達式替換後這可以用正則表達式來完成嗎?我也想用(Linux)sed試試這個,或者還有egrep,grep的方法。
egrep有一個選項--color = always但不是自定義高亮。
不客氣。如果我的答案解決了您的問題,請隨時通過點擊答案左側的投票計數下方的空白勾號圖標來接受此問題。 – Shef