Re: Ereg/replace/i/ or something ??
| From: | J Smith | Date: | Wed, 30 Jan 2002 16:11:56 +0000 |
| Subject: | Re: Ereg/replace/i/ or something ?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82761@lists.php.net to get a copy of this message | ||
Try
ereg("^[0-9]{10}$", $cust_tel);
Quick explanation (I get the feeling you're new at regexes):
^ - beginning of string
[0-9] - any number between 0 and 9 inclusive
{10} - exactly ten times
$ - end of string
There ya go.
J
B. Verbeek wrote:
> Hello,
>
> I want to check the data from a form-field if it excists only of digits
> (0-9) and nothing else.
>
> How do I use the ereg()-function for this?
>
> >> ereg("[0-9]",$cust_tel, $cust_tel); <<
>
> It is also to turn it around but then the pattern will get larger because
> it has to contain:
> / "'.,-)(*&^%# a-z A-Z and so on...
>
> The field has to be 10 digits long and has to contain only digits!!!
>
>
> Can anyone help me?
>
> Regards,
>
> Bart