note 100955 deleted from function.preg-match by danbrown

From: Date: Wed, 17 Nov 2010 14:50:04 +0000
Subject: note 100955 deleted from function.preg-match by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174123@lists.php.net to get a copy of this message
Note Submitter: GT! ---- If You change Your pattern to ungreedy then it will work. <?php $str ='/^00+[0-1]+[0-1]+[0-1] +[0-1]+[0-1]+[0-1]+00+[0-1]+ [0-1]+[0-1]+[0-1]+[0-1]+[0-1]+00+ [0-1]+[0-1]+[0-1]+[0-1]+[0-1]+[0-1]+00/U'; if ((preg_match($str,"00000000000000000000000000"))) {echo "OK";} ?> Its due the fact that preg_match is greedy by default.

« previous php.notes (#174123) next »