As I understood the problem, the goal was not necessarily to detect wrong or illegal HTML, but to make sure the output was valid so that posts further down the page are not screwed up. I never suggested that the input be assumed to be valid; in fact the way I built my suggested solution was to detect valid anchors and to render everything else as text (with entities). I feel that my suggestion, while not complete, at least lends itself to being able to prevent user mistakes or ignorance from affecting other posts.

Oh, and when I mentioned nesting, I meant that the comment inside the anchor element would be treated by my regex like nesting. I know that what you wrote was in fact an example of a legal comment inside a single A element, but since there is no reason for a user to comment the code in a BBS post I felt the mangling of that was an acceptable loss.


LAI
:eof

In reply to Re^6: RegEx for incorrectly closed HTML attribute? by LAI
in thread RegEx for incorrectly closed HTML attribute? by Cody Pendant

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.