In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("scott [gts]") wrote:

> preg_match('/<blah(.*?)>/', $text, $matches)
> 
> in the case of perl regexp's, you have to specifically
> tell the regexp not to be greedy.  the "?" regexp modifier
> is how you do this.  (otherwise, the regexp will try and
> match the maximum amount of text that it can, which
> usually isnt what you want, since it'll match *eveything*
> between "blah" and the last occurance of ">" in the text)

More ways to achieve the same effect, using the "U" modifier to invert the 
greediness of a regex expression or sub-expression:

preg_match('/<blah(.*)>/U', $text, $matches)
preg_match('/<blah(.*?U)>/', $text, $matches)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to