替換詞我有這樣正則表達式的幫助與超級鏈接
"this TEST-001 is test TEST-001string TEST-001"
我都試過,但其應用的超鏈接到所有匹配的角色。
$re1='(TEST)'; # Word 1
$re2='(-)'; # Any Single Character 1
$re3='(\d+)'; # Integer Number 1
echo preg_replace("/([".$re1.$re2.$re3."])/", "<a href=/$1>$1</a>", $txt);
刪除'['和']'並使用'$ 0'而不是'$ 1'。 –
解決了謝謝.. – Lasith