Re: regex usage
| From: | Shawn McKenzie | Date: | Sun, 17 Feb 2008 15:54:53 +0000 |
| Subject: | Re: regex usage | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269430@lists.php.net to get a copy of this message | ||
Valedol wrote:
> Is there a mothod to check string`s length with regex or the only way is
> using strlen?
>
> I want string consisting of 4 digits
> and check string with this code:
>
> if (preg_match("/\d{4}/",$_POST[id]))
> { echo $_POST[id]; }
>
> but preg_match returns true when string consists of 4 or more digits
preg_match("/^\d{4}$/",$_POST['id'])