Re: Regular Expressions?

From: Date: Fri, 20 Apr 2001 05:51:51 +0000
Subject: Re: Regular Expressions?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49497@lists.php.net to get a copy of this message
Hi Jason, @ 1:43:19 AM on 4/20/2001, Jason Caldwell wrote: ... > I want to match any of the following: > 1.1 or a.a > or 1111.1111 or aaaa.aaaa <-- any number of digits (0-9) or alpha (a-z) > on either side of the dot. > if(eregi("^([0-9][a-z]\.[0-9][a-z]", $myArray[x])) Your parentheses are slightly wrong. if( eregi( "^ ( /* unmatched parens */ [0-9][a-z] /* only matches one digit or character */ \. /* matches period */ [0-9][a-z] /* only matches one digit or character */ ", $myArray[x] ) /* syntax error :) */ ) > Is this correct? I think I'm missing something. You want something like this: <?php /* eregi("^([[:alnum:]]+\.[[:alnum:]]+)", $myArray[x]) */ $string = 'aaa.aaa'; $string_2 = 'aaaaaa'; print(eregi("^([[:alnum:]]+\.[[:alnum:]]+)", $string) ? 'matched' : 'no match'); print(eregi("^([[:alnum:]]+\.[[:alnum:]]+)", $string_2) ? 'matched' : 'no match'); ?> > Thanks. > Jason -Brian -- PGP is spoken here: 0xE4D0C7C8 Please, DO NOT carbon copy me on list replies.

« previous php.general (#49497) next »