Re: Regular expression help?
| From: | Jas | Date: | Mon, 02 Feb 2004 21:56:45 +0000 |
| Subject: | Re: Regular expression help? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176627@lists.php.net to get a copy of this message | ||
Adam Bregenzer wrote:
On Mon, 2004-02-02 at 14:15, Jas wrote:JasI 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. Thanks, that worked like a charm.