I get the message that ereg_replace() is deprecated.
So, I want to change the following line
to use [man]preg_replace[/man]
$text = "<p>".ereg_replace("(\n){2,}", "</p><p>", $text)."</p>";
Thanks!
I get the message that ereg_replace() is deprecated.
So, I want to change the following line
to use [man]preg_replace[/man]
$text = "<p>".ereg_replace("(\n){2,}", "</p><p>", $text)."</p>";
Thanks!
I found it out myself.
Simply add / in begining and end.
$text = "<p>".preg_replace("/(\n){2,}/", "</p><p>", $text)."</p>";
Those slashes are called delimiters. Delimiters don't have to be slashes however.. they can be any non alpha-numeric, non whitespace non backslash character. You can read up about delimiters here:
http://www.php.net/manual/en/regexp.reference.delimiters.php
Also, from what I gather, you shouldn't need to use a capturing group for \n (as $1 isn't really being used). You could simply use /\n{2,}/
Yes, right.
No need to capture.
I know we can use for example ## as delimiters.
Actually I often prefer ## before //, because they have better visibility and differ more from other slashes, backslashes in the code.
Thanks, nrg_alpha
Good to have guys like you and Weedpacket, who can help us with more difficult regex.
halojoy;10940118 wrote:Yes, right.
Good to have guys like you and Weedpacket, who can help us with more difficult regex.
Don't forget NogDog and Laserlight.. they're good with regex too!
hi nrg_alpha!
can you read my new post??
http://www.phpbuilder.com/board/showthread.php?p=10950755#post10950755
[ i don't understand where am i wrong...
(ereg_replace deprecated: ereg_replace(".<!-- [-listado_ini-] -->(.)<!-- [-listado_fin-] -->.","\1",$string);
with: preg_replace("#.(<!-- [-listado_ini-] -->)(.)(<!-- [-listado_fin-] -->).#e","$2",$string);
this function doesn't work...) ]