Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat regex to determine if < or > is part of HTML tag
    primarykey
    data
    text
    <p>If I have HTML like this: <code>&lt;dsometext&lt;f&lt;legit&gt;&lt;/legit&gt; whatever</code></p> <p>What regex pattern do I use to switch <code>&lt;</code> to <code>&amp;lt;</code> before d and f.</p> <p>I think it's all <code>&lt;</code> which are not followed by a <code>&gt;</code> but I can't wrap the regex for that around my head. I have users typing HTML and then am using jQuery to wrap the HTML and parse the nodes, however bad interim markup blows it up, so I want to swap out the <code>&lt;</code></p> <p>Ideas?</p> <p><strong>Edit</strong></p> <p>I'm not trying to parse the HTML to valid HTML. I just want to knock out interim characters as users type and the HTML is updated on page. If they are typing <code>&lt;strong&gt;</code>, and are still at the <code>&lt;</code> and I try to put the HTML on the page, it will cause horrible markup. That's why I need to swap it out.</p> <p><strong>Answer</strong> I chose @pimvdb's answer because it correctly answers the question I asked.</p> <p>However to make the world happier, I found a much simpler way of doing things without using any regex. Basically I had an issue originally where [title] was in place of an element and it had no container element, guaranteed to just contain the title. Therefore changing innerHTML of anything would cause horrors. We simply added the wrapping element. The hesitation to do that and the cause of this thread was due to some crazy reasons specific to the app and backwards comparability for our users.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload