note 68872 deleted from function.preg-match-all by colder

From: Date: Mon, 16 Apr 2007 17:05:15 +0000
Subject: note 68872 deleted from function.preg-match-all by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125476@lists.php.net to get a copy of this message
Note Submitter: cp at ltur dot de ---- To Stabby at somewhere dot invalid, i guess you're not very familar with regexps. Here is the working version: <?php $pattern='/fred(.+)bloggs/isU'; $data="fred hello\nthere bloggs fred goodbye bloggs"; preg_match_all($pattern,$data,$repTxt,PREG_PATTERN_ORDER); print_r($repTxt); ?> 1. You have to set the 's' modifier, to make the '.' match newlines (see documentation) 2. if you write the capuring phrase like you did (.)+ it will capture a lot of single characters. If you change it to (.+) it will capture all allowed charakters. HTH Claus

« previous php.notes (#125476) next »