string string {format mat=34/} string string string string string string string string
string string {format mat=34/} string string string string string string string string
$圖案= 「/ {格式並[a-Z0-9 = \ S] * \ /}/I」;PHP - 正則表達式 - 多匹配結果
str_replace($ pattern,'test',$ strings);
它將替換字符串中的所有格式,我只想替換第一個「格式」,並刪除所有其他「格式」。怎麼樣 ?
當匹配結果是「{format mat = 34 /}」時。我想查找以「mat =」開頭的字符串。
所以我有這個
$string = "{format mat=34/}";
$pattern = "/^mat=[0-9]*/"; // result is null
$pattern = "/mat=[0-9]*/"; // ok, but also effect with "{format wrongformat=34/}"
如何匹配開頭的字符串 「墊=」
感謝,並以 「/ \ SMAT = [0-9] * /」 是足夠 – Chameron 2011-04-19 17:46:13