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

Fix random bug where regex doesn’t match every reg. expression #47

Closed
wants to merge 1 commit into from
Closed

Conversation

christophby
Copy link

Im my case it skipped random matches. This PR fixes it.

Copy link

@scottmas scottmas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I too faced this same annoying error and came upon the same fix, since RegExp.exec mutates the RegExp object

@scottmas
Copy link

scottmas commented Aug 15, 2018

In the meanwhile, while people are waiting for a fix, you can simply always ensure the pattern is a fresh instance in your render method.

const HASHTAG_REGEX = /#[a-z]+\b/i
...
{ pattern: new RegExp(HASHTAG_REGEX) }

@fbartho
Copy link
Contributor

fbartho commented Nov 15, 2018

@christophby & @scottmas I'd be happy to ship this if the suggested change was made, and if we add tests that exercise this bug, so we make sure not to have a regression.

Please merge in master before you do that as I've switched the test harness to jest. 🥂

@fbartho fbartho added the bug label Nov 15, 2018
Copy link
Contributor

@fbartho fbartho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shramadani
Copy link

Please apply:
https://github.com/taskrabbit/react-native-parsed-text/pull/47/files#r210374952

And please add tests!

Just tried this change locally and seems to be working as expected. Is it possible to merge this PR please?

@christophby christophby changed the title Fix random bug where regex dont matches every reg. expression Fix random bug where regex doesn’t match every reg. expression Nov 5, 2019
@fbartho
Copy link
Contributor

fbartho commented Nov 18, 2019

@shramadani -- if you want to help contribute tests for this PR, I'm looking to ship a new release of this this week. Please let me know if you're interested!

@ouoru
Copy link

ouoru commented Dec 5, 2019

@fbartho any updates on this? 😃

@fbartho
Copy link
Contributor

fbartho commented Jun 10, 2020

Since there are no current tests, I'm going to try to write some myself. Additionally, there was a comment that I requested get applied, and that was resolved (hidden) instead of applying it.

I probably will reset the regexp by setting .lastIndex = 0 before the while loop assuming that doesn't break things.

This means I'm probably not going to merge this PR as is. I hope you understand @christophby

fbartho added a commit that referenced this pull request Jun 11, 2020
Alternative implementation to #47
@fbartho
Copy link
Contributor

fbartho commented Jun 11, 2020

There is an alternative implementation in this commit: e8f140e

I will spin a beta build shortly

@fbartho fbartho mentioned this pull request Jun 11, 2020
@fbartho
Copy link
Contributor

fbartho commented Jun 11, 2020

[email protected] is now available on npm -- please let me know if you have any issues!

@fbartho
Copy link
Contributor

fbartho commented Jul 7, 2020

Closing this PR as there would now be conflicts, but please report if you have any issues with the current implementation, or if further fixes are necessary!

@fbartho fbartho closed this Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants