Looking for a useful regex? How about one that reflows text that’s been cut & pasted from a text email and consequently chopped at 72 chars/line?
Here goes:
print preg_replace("/\n(?!\n)/", "", $foo);
where $foo is your text. Not perfect yet but contributions welcome. Thanks to Andrew, who’s known as Mr. Walking Regular Expression around the office, for his help. Given a text pattern problem of arbitrary complexity, Andrew blinks twice then speaks the regex in reply.








February 3rd, 2006 at 1:21 pm
Thanks, that fixed an issue with a plugin for WordPress for me…
November 3rd, 2006 at 3:04 pm
Would love some more details on how you used this with WordPress.