Re: reg-ex problem
| From: | CC Zona | Date: | Wed, 07 Feb 2001 18:51:19 +0000 |
| Subject: | Re: reg-ex problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-38593@lists.php.net to get a copy of this message | ||
In article <3A81920C.1C53EE2D@fastsearch.com>, lee.stretton@fastsearch.com
(Lee Stretton) wrote:
<snip>
> elseif( preg_match( "/^[a-zA-Z]+$/", $arg[$i], $matches ) )
<snip>
> elseif( preg_match( "/(div\d|prem)/", $arg[$i], $matches ) )
<snip>
> The first 3 work fine, but the last one "/(div\d|prem)/" doesnt work
> properly. It does work if I have say div1, but if I have prem it doesnt
> work at all. I have tried changing the regex so it only contains
> "/prem/" and it still doesnt work. can anyone tell me what is wrong with
> this code, or is it just a bug in my version of php?
Your earlier test for "/^[a-zA-Z]+$/" catches any string that is all
letters from beginning to end. Thus a string == "prem" would be caught
above, and never reach the test for "/(div\d|prem)/".
--
CC