Forgive me, let me clarify myself:

I am actually using PHP (with PCRE extention enabled) to process user comments
on a small project I am working on. I want to limit the user to have a maximum
of one newline _per_ newline ... that does not make lots of sence ... let me try
to explain better.

The text for the comments is stored in a database. The scripts grab that text
and run it through a BBCode processor. The problem is, the extra BBCode tags
cause unnnececary newlines. After that, the text is ran through the nl2br()
function that converts all new lines to HTML <br /> elements. So ... using
BBCode tags will cause unwanted newlines and make the comment look different.

I think that after running the text through the BBCode processor, then replacing
all instences of more-then-one newline with a single newline is a good thing.

There are a couple of other reasons that I chose to do it this way, but I dont
want to get into that right now, its irelevent.

So what I am looking for it a search-replace Perl regex statement that does
this.

If any of that was confusing, please tell me so I can "clarify" it some more.


On Wed, May 05, 2004 at 10:20:43PM -0500, John J. Trammell wrote:
> On Wed, May 05, 2004 at 09:22:02PM -0500, Andrei Bazhgin wrote:
> > I am having some problems getting a PCRE to match more then one
> > newline.  Basicaly, I am filtering text ... and there can be no more
> > then one newline at any part of the text.
> 
> Not sure I follow you--if you're reading a file line-by-line,
> you're going to have to try something else.  But if you have
> the whole string in one variable, you should be able to do:
> 
>   s/\n+/\n/g;
> 
> -- 
> trammell at el-swifto.com  9EC7 BC6D E688 A184 9F58  FD4C 2C12 CC14 8ABA 36F5
> Twin Cities Linux Users Group (TCLUG)      Minneapolis/St. Paul, Minnesota
> 
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> http://www.mn-linux.org tclug-list at mn-linux.org
> https://mailman.real-time.com/mailman/listinfo/tclug-list
> 

-- 
Andrei Bazhgin
www.nan2d.com

_______________________________________________
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
http://www.mn-linux.org tclug-list at mn-linux.org
https://mailman.real-time.com/mailman/listinfo/tclug-list