You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Regular expressions with a global flag are not working right. The code uses regex.test() and regex.exec(), both increasing an internal lastIndex counter.
For example:
<Highlight search=/brown|jumps/g">The quick brown fox jumps over the lazy dog</Highlight>
will only highlight 'jumps' because the first conditional search.test(remainingCleaned) will move the lastIndex counter right after the 'brown' keyword. search.exec(subject) will then only find 'jumps'.
The text was updated successfully, but these errors were encountered:
@helior I think this simple change can be relevant for other users, and it extends the functionality because now you can highlight multiple keywords using a regular expression. It does not affect regular expressions without the global flag (because they don't use the lastIndex parameter).
Regular expressions with a global flag are not working right. The code uses
regex.test()
andregex.exec()
, both increasing an internal lastIndex counter.For example:
will only highlight 'jumps' because the first conditional
search.test(remainingCleaned)
will move the lastIndex counter right after the 'brown' keyword.search.exec(subject)
will then only find 'jumps'.The text was updated successfully, but these errors were encountered: