The user will provide some search term. Let's just say it's a string, that may contain any words or special characters (like /
, ?
, ,
, $
, *
, etc).
I need to match this sequence of characters anywhere they appear in HTML, even if the search term crosses sequential spans; in my HTML, special characters are sometimes wrapped separately.
For example: the user provides "Your mom?", and there is a paragraph which contains <span>Your mom</span><span class="special">?</span>
I need an effective way to determine that a) the query does exist, and b) which elements contain the query. The searched text can be complex HTML, and contain LOTS of words, spans, divs, etc.