note 100955 added to function.preg-match

From: Date: Wed, 17 Nov 2010 09:24:33 +0000
Subject: note 100955 added to function.preg-match
Groups: php.notes 
Request: Send a blank email to php-notes+get-174107@lists.php.net to get a copy of this message
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. ---- Server IP: 64.71.164.2 Probable Submitter: 153.2.246.32 ---- Manual Page -- http://www.php.net/manual/en/function.preg-match.php Edit -- https://master.php.net/note/edit/100955 Del: integrated -- https://master.php.net/note/delete/100955/integrated Del: useless -- https://master.php.net/note/delete/100955/useless Del: bad code -- https://master.php.net/note/delete/100955/bad+code Del: spam -- https://master.php.net/note/delete/100955/spam Del: non-english -- https://master.php.net/note/delete/100955/non-english Del: in docs -- https://master.php.net/note/delete/100955/in+docs Del: other reasons-- https://master.php.net/note/delete/100955 Reject -- https://master.php.net/note/reject/100955 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174107) next »