Re: preg_replace help!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



thanks, its fixed now!!!
----- Original Message ----- From: Martin Alterisio
To: Nathan Heaps
Cc: Liber ; John Hicks ; php-db@xxxxxxxxxxxxx
Sent: Thursday, May 04, 2006 11:34 AM
Subject: Re:  preg_replace help!





2006/5/4, Martin Alterisio <malterisio777@xxxxxxxxx>:
2006/5/3, Nathan Heaps <nathan42100@xxxxxxxxxxx>:
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
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux