thanks to all for the great suggestions. they're all very helpful.

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.


In reply to Re: regex to replace linefeeds with <p> tags by jck
in thread regex to replace linefeeds with <p> tags by jck

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.