Re: eregi help please
| From: | Jeff Lacy | Date: | Tue, 17 Oct 2000 18:04:11 +0000 |
| Subject: | Re: eregi help please | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20674@lists.php.net to get a copy of this message | ||
Opps. Typo. I must have misplaced that darn ^. Let me try this once more:
if (eregi("^[a-z09. ]+$", $string)) {
No need to be huffy Luke! I just make a little typo.
""Jeff Lacy"" <jeffdl@mn.mediaone.net> wrote in message news:8shuet$jmi$1@toye.p.sourceforge.net...
> I am using
>
> if (eregi("[a-z0-9. ]+$", $string)) {
>
> and it works just like a charm. Thanks, Hardy.
>
>
>
> "Hardy Merrill" <merrill@missioncriticallinux.com> wrote in message
> news:20001017121216.A15815@merrill.lowell.mclinux.com...
> > Jeff Lacy [jeffdl@mn.mediaone.net] wrote:
> > > Could some kind soul please help me with eregi? I need something that
> will return true if $string doesn't contain anything other than a-z or 0-9
> or . or a space. The best thing I have been able to come up with is
> > >
> > > if (eregi("([a-z]|[0-9]|[.]|[[:space:]])+", $string) {
> >
> > How 'bout
> >
> > if (eregi("^[a-zA-Z\. ]+$", $string)) {
> >
> > I'm more experienced with Perl, so I'm not sure this works, but
> > the concept is - return true if the only characters in the string
> > are letters, periods, and spaces - use the carrot "^" to anchor
> > the regex to the beginning and the dollar sign "$" to anchor the
> > regex to the end - meaning that *ALL* characters in between must
> > match the regex in order to return true. I'm not sure "eregi"
> > uses the ^ and $ as anchors, and at the moment I can't try thiss
> > to confirm it.
> >
> > If you want to return true if you find anything *BUT* those characters,
> > you can use this:
> >
> > if (eregi("[^a-zA-Z\. ]+", $string)) {
> >
> > The carrot at the beginning of the *inside* of the square
> > brackets says "not" - so will return true if it finds any
> > characters which are NOT one of the ones listed.
> >
> > Again, test this, because I'm not sure what PHP's eregi
> > uses in comparison to Perl's regex operators.
> >
> > HTH.
> >
> > --
> > Hardy Merrill
> > Mission Critical Linux, Inc.
> > http://www.missioncriticallinux.com
> >
> > > echo "$string is okay";
> > > }
> > > else {
> > > echo "$string is wrong, you fool!!!";
> > > }
> > >
> > > That doesn't work quite right, though. Could you please help me with
> it? Thank you so much!
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>