[pmwiki-users] Dumb question... stripping returns?
Patrick R. Michaud
pmichaud at pobox.com
Mon Aug 8 13:28:22 CDT 2005
On Mon, Aug 08, 2005 at 01:15:04AM -0400, Russell Bailey wrote:
> I'd like to strip out extraneous carriage returns in user edits. I'm
> having a devil of a time getting the replace string right, though. I'm
> pretty sure I'm making a simple error... anyone recognize it?
>
> $new['text'] = str_replace("/[\n|\r]{2,}/", '\n', $new['text']);
str_replace doesn't do pattern matching -- just direct string
substitutions. You probably want preg_replace:
$new['text'] = preg_replace("/[\n\r]+/", "\n", $new['text']);
Pm
More information about the pmwiki-users
mailing list