markRegExp locking up
See original GitHub issueWhen using markRegExp
, some “partial matching” regular expressions will cause the browser to lock up.
For example, using this demo for reference:
- When a regular expression of
/(lorem|ipsum)/gi
is entered into the input; the result is as expected. - As you delete letters from the end of the second word… you’ll get to this point:
/(lorem|i)/gi
. - Then, deleting the last letter
i
will give you this regular expression:/(lorem|)/gi
which locks up the browser.
I’ve tested this from the console with the same result.
$(".context").unmark().markRegExp(/(lorem|)/gi);
It probably isn’t in an infinite loop, it’s just trying to match an enormous number of empty strings:
'Lorem ipsum dolor sit āmet'.match(/(lorem|)/gi)
// results: ["Lorem", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (8 by maintainers)
Top Results From Across the Web
mark.js example with jQuery - JSFiddle - Code Playground
See {@link Mark#mark}, {@link Mark#markRegExp} and ... Sets up the regular expression string to allow later insertion of ... a closing "(".
Read more >Highlight a word with jQuery - javascript - Stack Overflow
mark("keyword"); // Highlight the custom regular expression in the specified context $(".context").markRegExp(/Lorem/gmi);. It's free and ...
Read more >Gnus Manual - GNU.org
If this variable is nil , Gnus will ask for group info in total lock-step, which isn't very fast. If it is some...
Read more >Documentation for Org hooks, commands and options
This page lists all hooks, commands and options of Org 9.0.9. Hooks: are options containing functions to be run before or after a...
Read more >mark.js – JavaScript keyword highlight
jQuery: $(".context").markRegExp(regexp [, options]);. Note: Even if this is a chaining method ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Use
/\S/
or/.+/
.Finally done! Check out the tablesorter mark widget demo.