Re: Regular expression help?
| From: | Adam Bregenzer | Date: | Mon, 02 Feb 2004 19:50:45 +0000 |
| Subject: | Re: Regular expression help? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176604@lists.php.net to get a copy of this message | ||
On Mon, 2004-02-02 at 14:15, Jas wrote:
> 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'])
>
> so it should match 2 characters 0-9a-fA-F
> each block of 2 characters is followed by a : and repreated in 6
> blocks.
That's a long expression, try:
!preg_match('/^([0-9a-f]{2}($|:)){6}/i', $_POST['mac']);
This pattern finds 6 matches of a number or letter (the /i means
case-insensitive) followed by either a ':' or the end of the string.
--
Adam Bregenzer
adam@bregenzer.net