Thursday, 13 December 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
php - file_get_contents shows unexpected output while reading a file
I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...
-
I have an app which needs a login and a registration with SQLite. I have the database and a user can login and register. But i would like th...
-
I got an error in my Java program. I think this happens because of the constructor is not intialized properly. My Base class Program public ...
-
I would like to use enhanced REP MOVSB (ERMSB) to get a high bandwidth for a custom memcpy . ERMSB was introduced with the Ivy Bridge micro...
No comments:
Post a Comment