Thursday, December 13, 2018
javascript - JS highlight matched content x times
Answer
How can you highlight x occurrences
How can you highlight, in pure JS only, a limited subset of matches from a set of text so that only x number of highlights occur per match.
var matches = new Array('fox', 'dog');
var MaxHighlights = 2;
Original content
The quick brown fox jumps over the lazy dog but the lazy dog is quick of the mark to catch the brown fox. In general the fox versus the dog is not a good match.
Highlighted content
The quick brown fox jumps over the lazy dog but the lazy dog is quick of the mark to catch the brown fox. In general the fox versus the dog is not a good match.
For extra points I'd preferably only highlight one match per sentence.
Preferred Highlighted content
The quick brown fox jumps over the lazy dog but the lazy dog is quick of the mark to catch the brown fox. In general the fox versus the dog is not a good match.
I was using this is a base for my highlighting attempts
http://www.the-art-of-web.com/javascript/search-highlight
plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV
In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...
-
When the left part is an object instance, you use -> . Otherwise, you use :: . This means that -> is mostly used to access instance m...
-
This question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programm...
-
I am new to dask and I found so nice to have a module that makes it easy to get parallelization. I am working on a project where I was able ...
No comments:
Post a Comment