Re: reg-ex problem

From: Date: Wed, 07 Feb 2001 21:16:36 +0000
Subject: Re: reg-ex problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-38620@lists.php.net to get a copy of this message
On Wednesday 07 February 2001 21:50, Michael Dearman wrote: > > } > > elseif( preg_match( "/^\d+$/", $arg[$i], $matches ) ) > > Isn't this \d+ matching ----------^ > > > { > > $value = $matches[0]; > > } > > elseif( preg_match( "/(div\d|prem)/", $arg[$i], $matches ) ) > > the \d in this-----------------^------------^ No. the 1st expression is /^\d+$/ , i.e. match strings with at least one decimal number and nothing else (\d+) from their beginning (^) to their end ($) I.e. that one only catches strings consisting only of decimal digits. > And the | is using '\d' and 'prem'. It probably should be > "/(div\d)|prem/ Unless those parens are part of the expression. Then No, that's fine. (div\d|prem) means "match either 'div\d' or 'prem'" and memorize that part -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) "These are the people who proudly call themselves "hackers" -- not as the term is now abused by journalists to mean a computer criminal, but in its true and original sense of an enthusiast, an artist, a tinkerer, a problem solver, an expert." - ESR

« previous php.general (#38620) next »