Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for regex with global flag. #60

Open
bram-ontoforce opened this issue Sep 20, 2018 · 2 comments
Open

Add support for regex with global flag. #60

bram-ontoforce opened this issue Sep 20, 2018 · 2 comments

Comments

@bram-ontoforce
Copy link

bram-ontoforce commented Sep 20, 2018

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'.

@bram-ontoforce
Copy link
Author

bram-ontoforce commented Sep 21, 2018

@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).

@mihaiserban
Copy link

any news on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants