question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

markRegExp locking up

See original GitHub issue

When 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:closed
  • Created 7 years ago
  • Comments:22 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Mottiecommented, Sep 6, 2016

Use /\S/ or /.+/.

1reaction
Mottiecommented, Aug 1, 2016

Finally done! Check out the tablesorter mark widget demo.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found