In the official docs about the method Selection.addRange()
I can select the element when I have the specific range, but I don't know how to get the range for a specific word/target which is part of a text
Example:
<p>Hello world</p>
and I want to add the range selection for world
like I would mark it manually with my mouse cursor.
Additionally: How can I select a specific text and mark it based on some Regex rules?
I couldn't find an answer on SO so far.
Official Mozilla docs about addRange()
: https://developer.mozilla.org/en-US/docs/Web/API/Selection/addRange