You are here: regular expressions conditional replace « PHP Language « IT news, forums, messages
regular expressions conditional replace

Posted by Mig21 on 05/16/05 03:04

hi

i am trying to make a bbcode parser and i get stuck at this :(

i want to replace all '\n' with "<br />\n" in a text unless it's in
between <pre></pre> tags. i can't figure out a way to conditionally
replace anything.

for example, this text:
---
some text here
<pre>some
more
text here !</pre>
outside
lala
---

would become, if it was working:
---
some text here<br />
<pre>some
more
text here !</pre>
outside<br />
lala<br />
---

now all i have is:
$step4 = preg_replace("#\n#is", "<br />\n", $step3);

which replaces all newlines, even inside <pre>

please help!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация