in reply to regex to replace linefeeds with <p> tags
liverpole, i agree with you, and i was thinking that i would just leave out the linefeeds, but when the posts are long, i don't like seeing the text all strung together without easily seeing the paragraph breaks - just a preference thing.
a general question about the \r ? that both Joost and throop suggest......i started out with \n{2,} but found that some of my users were cutting an pasting from word processors, and that introduced the occasional \r into the mix. so, will [ (\r? \n){2,} ] match to "\r\r" ? that was what i was hoping would work with the \r\n{2,} - that it would match to \r\r or \r\n or \n\r or \n\n (as well as \r\r\n and \r\n\r and \r\n\n and \n\n\r etc etc etc.....)
clearly, passing through twice, and changing any \r to \n and then matching the \n{2,} to replace to the para tags would be reliable, but seems inefficient.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex to replace linefeeds with <p> tags
by throop (Chaplain) on Dec 26, 2006 at 03:48 UTC |