Re: preg_replace help!

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

 



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

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

  Powered by Linux