Re: PCRE - catching a caracter set in a negative class

From: Date: Thu, 11 Apr 2002 14:34:10 +0000
Subject: Re: PCRE - catching a caracter set in a negative class
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-92581@lists.php.net to get a copy of this message
Yo Maxim: On Wed, Apr 10, 2002 at 10:48:42AM +0900, Maxim Maletsky wrote: > > $text = ' > some text ... > {php} > echo "some funcy code to include he{re"; > {/php} > '; > > $out = preg_split("/(\{php}[^\{php}]*\{\/php})/i", $text, -1, > PREG_SPLIT_DELIM_CAPTURE); Your middle segment, "[^\{php}]*" is telling the system to took for any character that's not a "{", "p", "h", or "}", and perhaps even a "\". So, any time it encounters one of those characters, the regex evaluates to false. It's best to replace it with ".*" and add the "ms" flags. $out = preg_split("/({php}.*{\/php})/ims", $text, -1, PREG_SPLIT_DELIM_CAPTURE); I don't know if this does what you really want it to since what it does is kind of strange and you didn't specify what your goal is. Good luck, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

« previous php.general (#92581) next »