Thanks for the feedback.

Here was my problem; I misunderstood how the "+" worked. It only applies to the last "\n", not both "n\n".



Hans Juergen Von Lengerke wrote:

From: Al <[EMAIL PROTECTED]>

$text= preg_replace("/\n\n+/", "\n\n", $text);
// remove excess This doesn't seem to do anything.




Strange, your code works for me:

[EMAIL PROTECTED]:~ > cat foo.php
<?php
 $text = "foo\n\n\n\n\nbar";
 echo "before:\n===\n$text\n===\n\n";
 $text = preg_replace("/\n\n+/", "\n\n", $text);
 echo "after:\n===\n$text\n===\n\n";
?>
[EMAIL PROTECTED]:~ > php ./foo.php
before:
===
foo




bar ===

after:
===
foo

bar
===

[EMAIL PROTECTED]:~ > php -v
PHP 4.3.4 (cli) (built: Feb 12 2004 17:42:41)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend
Technologies
[EMAIL PROTECTED]:~ >



-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to