Preg_match matching mac address solution

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.