View Single Post

  #2 (permalink)  
Old 02-26-2005
Andy Hassall
 
Posts: n/a
Default Re: How do I remove extra line breaks beyond two?

On 25 Feb 2005 15:25:17 -0800, revjjjames@hotmail.com wrote:

>What is the correct expression to remove any extra line breaks beyond
>two in a string?


There any may ways but I'd probably use something like:

$string = preg_replace('/(?<=\n)(\n?)\n*/s', "$1", $string);

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Reply With Quote