Home » Javascript » Search (and highlight) text inside html document

Search (and highlight) text inside html document

Posted by: admin August 19, 2018 Leave a comment

Questions:

I am looking for a library or a piece of code that would allow arbitrary plain text to be searched and located (start/stop offsets or tags) inside an html document.

Example:

  • pattern to look for: “text that I’m looking for”
  • html document:
<html>...<p>text that <b>I'm</b/> <span>looking
   for<div>...</div>...</p>
  • resulting match:

text that <b>I'm</b/> <span>looking for

Does anyone know of such utility?
thanks

Answers: