Re: preg_replace help!

From: Date: Thu, 04 May 2006 19:52:28 +0000
Subject: Re: preg_replace help!
References: 1 2 3 4  Groups: php.db 
Request: Send a blank email to php-db+get-41818@lists.php.net to get a copy of this message
thanks, its fixed now!!! ----- Original Message ----- From: Martin Alterisio To: Nathan Heaps Cc: Liber ; John Hicks ; php-db@lists.php.net Sent: Thursday, May 04, 2006 11:34 AM Subject: Re: [PHP-DB] preg_replace help! 2006/5/4, Martin Alterisio <malterisio777@gmail.com>: 2006/5/3, Nathan Heaps <nathan42100@student.com>: Ok, scratch that, new problem. what can I replace (.*?) with in order for php to recognise a multi-line quote/bold/italic/code/whatever? By default the "." pattern matches anything except a line break you can either use ((?:.|\n)*) or add a modifier to the regular expression that changes the behaviour of the "." pattern. Modifiers are appended at the end of the regular expression, after the closing delimiter: /\[i:(.*?)\](.*?)\[\/i:(.*?)\]/s The "s" modifier tells the regular expression to captura any character with an "." pattern. With only this you should be able to captura multiline tags. Also you should consider using the "U" modifier which makes all repetition patters (*,+) ungreedy. This way you can avoid using the "?" after Sorry, las message wasn't send properly (gmail isn't working right anymore for me). The last part was cutoff, it said: Also you should consider using the "U" modifier which makes all repetition patters (*,+) ungreedy. This way you can avoid using the "?" after all repeated patterns: /\[i:(.*)\](.*)\[\/i:(.*)\]/sU

« previous php.db (#41818) next »