Home > Backend Development > PHP Tutorial > preg_match 匹配mac地址解决方案

preg_match 匹配mac地址解决方案

WBOY
Release: 2016-06-13 10:07:04
Original
1150 people have browsed it

preg_match 匹配mac地址

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->    $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);
Copy after login

这个是程序员写的 我在学习 我希望可以指定mac地址  
所以我将其修改如下
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$isMac = preg_match("/00:e0:c2:e1:a3:85/i", $mac);
Copy after login

但是不给力啊  

我看了看中文手册 好像没问题的说 
请指教 小弟学习中

------解决方案--------------------
你这个,直接用strpos就可以了。。。
------解决方案--------------------
lz的困惑是他的匹配mac地址的正则写的是否正确。
------解决方案--------------------
探讨

引用:

你有什么困惑?

$isMac = preg_match("/00:e0:c2:e1:a3:85/i", $mac);这样写可以么?

------解决方案--------------------
不明白。既然固定的字符串 为什么要用 正则表达式处理。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template