Re: regular expressions question

From: Date: Wed, 05 Mar 2008 00:30:27 +0000
Subject: Re: regular expressions question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-270988@lists.php.net to get a copy of this message
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@l-i-e.com> 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

« previous php.general (#270988) next »