Re: regular expressions question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you guys,

The answers you gave me not only solved the problem,
but i included more characters like space and -.

Thank you again

--- Richard Lynch <ceo@xxxxxxxxx> wrote:

> 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);
> 
> This will:
> ^ "anchor" the string at the beginning
> [a-z]+ a to z, with at least one letter
> $ "anchor" the string at the end
> 
> Note, however, that some people have other
> characters in their first
> name, such as apostrophe, space, and dash.
> 
> Oh, and the digit 3, for "bo3b" who was a programmer
> on the first
> Apple Macintosh.  His parents were hippies, and that
> really is his
> name...
> 
> You may want to obtain a LARGE list of "first names"
> and run them
> through your validator as a test.
> 
> -- 
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
> 
> 



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux