preg_match()-正規式字串比對與剖析
preg_match($pattern, $subject, $matches,[$flags])說明:
$pattern:正規式文字字串規則。
$subject:欲比對之字串。
$matches:比對結果傳回的值放在陣列參數。
$flags:此為選項,可設定PREG_PATTERN_ORDER及PREG_SET_ORDER,預設為PREG_PATTERN_ORDER。
本函式以 $pattern 的規則來剖析比對字串 $subject。比對結果傳回的值放在陣列參數 $matches 之中,若省略參數 matches,則只是單純地比對,找到則傳回值為 true。
程式碼範例:
執行結果:
頁:
[1]