cool, glad you got it working...if you think there's a bug with using / and
| you might want to see if you can replicate the problem, and if its really
a bug, submit it...my guess is that it was just a typo or something

jack

-----Original Message-----
From: Ken [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 06, 2001 5:13 PM
To: Jack Dempsey; PHP list
Subject: RE: [PHP] Reg ex help-Removing extra blank spaces before HTML
output


OK, this time the \n worked.  The only thing I changed was using /
delimiters instead of | delimiters in the search string.  No idea if/why
that would affect anything in the replacement string.

Anyway, I finally came up with exactly what I wanted:
preg_replace(array("/\s*\n+\s*/", "/[ ]+/"), array("\n", " "), $input);

All padding (defined as any series of spaces, newlines and sometimes tabs)
is removed from $input, but always leaving at least a space or a newline in
its place.  If there were any newlines in the "padding", then a newline is
left.  If there weren't, then a space is left.

Thanks for the help!

Ken
[EMAIL PROTECTED]

At 04:40 PM 12/6/01 -0500, Jack Dempsey wrote:
>one call to preg_replace...if you check out php.net/preg_replace, you'll
see
>what i mean...use arrays...
>and as long as you have them ordered in the right way, it'll execute them
in
>that order, so by the time the \s replace comes up all your 'bbbnbb' will
be
>fixed...problem then is that those newlines would get caught by the \s and
>get switched to spaces...so, if you want them to stay, then use [ ] to
>represent a space instead of \s...might want [ \t] to catch tabs as well...



-- 
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]

Reply via email to