Re: regular expressions question
| From: | Robert Cummings | Date: | Wed, 05 Mar 2008 15:27:04 +0000 |
| Subject: | Re: regular expressions question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271016@lists.php.net to get a copy of this message | ||
On Wed, 2008-03-05 at 07:13 -0800, It Maq wrote:
> Hi,
>
> I am using that right now and i have don't know how to include blank fields. For example
> if a user does not fill a field in a form i want to accept it. I tried the code you posted, for now
> it is blocking blank fields.
>
> Thank you
>
> ----- Original Message ----
> From: Richard Lynch <ceo@l-i-e.com>
> To: Adil Drissi <adil.drissi@yahoo.com>
> Cc: php-general@lists.php.net
> Sent: Tuesday, March 4, 2008 3:09:09 PM
> Subject: Re: [PHP] regular expressions question
>
> On Tue, March 4, 2008 1:19 pm, Adil Drissi wrote:
> > Is there any way to limit the user to a set of characters for example
> > say i want my user to enter any character between a and z (case
> > insensitive). And if the user enters just one letter not belonging to
> > [a-z], this will not be accepted.
> >
> > I tried eregi('[a-z]', $fname) but this allows the user to enter
> > abdg4512kdkdk for example.
>
> What you tried only requires ONE a-z character somewhere in the input.
>
> Try this:
>
> preg_match('^[a-z]+$', $fname);
preg_match('^[a-z]*$', $fname);
Someone else posted this also, but you may have missed it.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP