Re: Regular expression help?

From: Date: Mon, 02 Feb 2004 19:29:13 +0000
Subject: Re: Regular expression help?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176600@lists.php.net to get a copy of this message
* Jas <jason.gerfen@scl.utah.edu>: > Not sure if anyone knows of a good way to match strings of this type... > 00:02:8b:0c:2f:09 > > I have tried this but its not working. > > > !eregi("^[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}$",$_POST['mac']) Use the perl compatible regexps instead: !preg_match('/^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$/', $_POST['mac']) This searches for XX: 5 followed by XX, where XX is 0-9, A-F, or a-f. I _think_ the POSIX regexps can do some grouping like this as well, but I'm not absolutely sure. -- Matthew Weier O'Phinney Webmaster and IT Specialist National Gardening Association 802-863-5251 x156 mailto:matthew@garden.org http://www.garden.org http://www.kidsgardening.com

« previous php.general (#176600) next »