Find all matching DOM ranges for a given text string.
var rangeLookup = require('range-lookup');
var ranges = rangeLookup('some string');
ranges
//=> Array [ Range, Range, Range, Range ]
// Highlight ranges.
var selection = window.getSelection();
ranges.forEach(selection.addRange.bind(selection));
query
— string to search for.
Returns array of matching ranges.
Whether to ignore case while attempting a match in a string. Defaults to false
.
- This module is not capable of matching text that crosses text nodes boundaries.
npm install range-lookup
MIT