Thanks David!! I was trying to do it all in one shot and was getting some "amusing" results. Your method is much more straightforward and easier to understand. Peter On 3 Dec 2002 at 11:21, David A. Sinck wrote: > > > \_ SMTP quoth az_pete@cactusfamily.com on 12/3/2002 11:04 as having spake thusly: > \_ > \_ Hi All, > \_ > \_ I seem to be having a lot of trouble with what seems should be a > \_ simple regex. > \_ > \_ I have a database full of research paper abstracts and I would like > \_ to strip all newlines from them. This would include \n, \r, and > \_ \r\n characters. However, if there are two consecutive newlines > \_ (i.e. new paragraph) I would like to keep those in tact. > \_ > \_ I have written the script in PHP to pull each field from the > \_ database, perform said regex and then update the field with the new > \_ data. All I need is a regex that works. I'm using the Perl > \_ compatible regex within PHP. > \_ > \_ Any help would be appreciated. > > I'd do two passes for ease of thought: > > s/\r//g; # lose all \r's, regardless > > s/[^\n][\n][^\n]/ /g; # non-newline newline non-newline goes to space > > YMMV. > > Trying to do both in one could prove more amusing and is left as an > exercise for the reader. > > Backups are your friend. > > David > --------------------------------------------------- > PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us > To subscribe, unsubscribe, or to change you mail settings: > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss > >