Preg_match match mac address PHPcode $ isMac = preg_match (& quot;/^ [A-F0-9] {2}: [A-F0-9] {2}: [A-F0-9] {2 }: [A-F0-9] {2}: [A-F0-9] {2}: [A-F0-9] {2} $/I & qu preg_match match mac address
PHP code
$isMac = preg_match("/^[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}$/i", $mac);
This is written by a programmer. I am studying and want to specify a mac address.
So I modified it as follows:
PHP code
$isMac = preg_match("/00:e0:c2:e1:a3:85/i", $mac);
But not powerful.
I looked at the Chinese manual and said it was okay.
Please advise your younger brother
------ Solution --------------------
You can use strpos directly...
------ Solution --------------------
Lz's confusion is whether his regular expression matching the mac address is correct.
------ Solution --------------------
Discussion
Reference:
Are you confused?
$ IsMac = preg_match ("/00: e0: c2: e1: a3: 85/I", $ mac); can this be done?
------ Solution --------------------
I don't understand. Since the regular expression is used to process a fixed string.