using "\n" as your replacement text will do it....however, if you want a newline in the html, then you'll want <br>...
and as far as the advanced replace, make an array of search patterns, in this case two. your first pattern will be "/[ ]+\n+[ ]+/" with a replacement of a single newline...then the second will be the previous regex.....check out php.net for help with syntax and using arrays with preg_* functions....the first should catch all situations of a series of spaces [with at least one newline in between them] and substitute a newline..... check out mastering regular expressions as well.....its worth the money.... jack -----Original Message----- From: Ken [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 06, 2001 3:08 AM To: Jack Dempsey; liljim; PHP list Subject: RE: [PHP] Reg ex help-Removing extra blank spaces before HTML output At 02:43 PM 12/5/01 -0500, Jack Dempsey wrote: >$t = preg_replace('/\s+/',' ',$text); One more thing: How do I replace with newline instead of a space? I read through the manuals but couldn't grasp how to do this. \n didn't cut it. And, more advanced - The above replaces any groups of 2 or more blanks (newlines, spaces, tabs) with a single blank. Is there an easy way to replace them with EITHER a space or a newline, depending on whether any newlines were present in the input? I.e. bbbbbbbbbbbbbb would be replaced with b, but bbbbbnbbbbbnbbbb would be replaced with n. Right now the issue is that I'm sometimes getting results that have no line breaks for a really long time, and I know there are reasons to try to avoid individual lines of HTML longer than 200 characters. Thanks! - Ken [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]