這段代碼匹配出了3個結果
$pattern = '/^\w+(\.\w+)*@\w+(\.\w+)+$/';
$subject = '[email protected]';
$matchs = array();
preg_match($pattern, $subject,$matchs);
show($matchs);
結果是:
Array
(
? ?[0] => [email protected]
? ?[1] =>
? ?[2] => .com
)
看不出問題?各位幫忙解釋一下!
$pattern = '/^\w+(\.\w+)*@\w+(\.\w+)+$/';
$subject = '[email protected]';
$matchs = array();
preg_match($pattern, $subject,$matchs);
show($matchs);
結果是:
Array
(
? ?[0] => [email protected]
? ?[1] =>
? ?[2] => .com
)
看不出問題?各位幫忙解釋一下!
2017-09-16
舉報
2017-09-26
[1]=> 為空是因為你的第一個正則表達式的子模式(\.\w+)未匹配到任何字符,[2]=>.com是第二個子模式(\.\w+)匹配的字符是“.com”