Re: Need regular match help - possibly

From: Date: Thu, 22 Nov 2001 09:17:12 +0000
Subject: Re: Need regular match help - possibly
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75482@lists.php.net to get a copy of this message
Hello Gaylen, try this: $string = preg_replace("/\n{3,}/", "\n\n\n", $string); James "Gaylen Fraley" <gfraley5@earthlink.net> wrote in message news:20011122035622.91897.qmail@pb1.pair.com... > I need a routine that will allow me to trap multiple <br> and/or line feed > characters and convert them to a constant number. As an example, let's say > that you have text that has 10 carriage returns and/or line feeds. I want > to limit this to 3. So, I need to be able to parse the line to detect the > multiple control characters and convert the string to 3. So if the string > looked something like: > > This is \n\n\n\n\n\n\n\n\n\n a test. > > I would want it converted to > > This is \n\n\n a test. > > > Conceivably, it could be > > This is <br><br><br><br><br> a test. > > I would want it converted to > > This is <br><br><br> a test. > > > I know I could write a do/while loop, but I was wondering if there is a way > using eregi_replace or something along that line? > > Thanks! > >

« previous php.general (#75482) next »