Re: strip out too many newlines
| From: | Sebastian | Date: | Thu, 04 Aug 2005 14:39:03 +0000 |
| Subject: | Re: strip out too many newlines | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-220004@lists.php.net to get a copy of this message | ||
thanx for the reply, but 1 problem. there is not only \n there are \r in the POST too (carriage returns) so a string can look like this:
$string = '[quote=xx]\r\nfoo\r\n[/quote]\r\nmore text\r\n\r\n\r\n\r\n';
and your regexp will only catch if there is just \n
any solution for \r\n in combination too?
ty.
Marco Tabini wrote:
Don't know much about the app you're writing, but does this do the trick for you? echo preg_replace ('!-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.338 / Virus Database: 267.10.0/63 - Release Date: 8/3/2005( \[quote (?:=[^\]]*)? \] ) # Capture the [quote=xxx] part \n* # Eliminate any extra newlines here (.+) # Get contents \n* # Eliminate any extra newlines here (\[/quote\]) # Capture this part \n* # Eliminate any extra newlines here !x', "\$1\$2\$3\n\n", $string);HTH, Marco -- BeebleX - The PHP Search Engine http://beeblex.com On 8/4/05 9:44 AM, "Sebastian" <sebastian@broadbandgaming.net> wrote:[quote=user] foo [/quote] <bunch of extra lines> more text...