reg-ex problem

From: Date: Wed, 07 Feb 2001 18:21:00 +0000
Subject: reg-ex problem
Groups: php.general 
Request: Send a blank email to php-general+get-38585@lists.php.net to get a copy of this message
Hi, I am using regular expressions in a php program to decide what should be done next. I am having a problem with one of my regex's. The following is the code i am using: for( $i = 0; $i < sizeof( $arg ); $i++ ) { if( $arg[$i] == '' ) { continue; } if( preg_match( "/^\d{4}-\d{4}$/", $arg[$i], $matches ) ) { $season = $matches[0]; } elseif( preg_match( "/^[a-zA-Z]+$/", $arg[$i], $matches ) ) { if( ! isset( $display ) ) { $display = $matches[0]; } } elseif( preg_match( "/^\d+$/", $arg[$i], $matches ) ) { $value = $matches[0]; } elseif( preg_match( "/(div\d|prem)/", $arg[$i], $matches ) ) { $division = $matches[0]; }echo $arg[$i]."***<br>"; echo $division; } 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? Thanks in advance, Lee Stretton.

« previous php.general (#38585) next »