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(stdlib): Fix anchoring behavior in Regex.replaceAll #1440

Merged
merged 1 commit into from
Oct 6, 2022

Conversation

peblair
Copy link
Member

@peblair peblair commented Oct 3, 2022

Fixes #1431.

@peblair peblair requested a review from a team October 3, 2022 10:13
let poss = searchMatch(
rx,
buf,
searchPos,
searchPos,
Copy link
Member Author

Choose a reason for hiding this comment

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

This was breaking the anchoring behavior, since the "am I at the start of the input?" check always succeeded due to us saying that the input started at searchPos (the current position). For the regular expression ^., the lookbehind is 1, so this will be 0 when searchPos == 0 and searchPos - 1 for every other position.

Copy link
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

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

Looks great!

Copy link
Member

@phated phated left a comment

Choose a reason for hiding this comment

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

Thanks for digging into this! 🙇‍♂️

@peblair peblair merged commit d513eff into main Oct 6, 2022
@peblair peblair deleted the philip/fix-regex-replaceall branch October 6, 2022 07:25
@github-actions github-actions bot mentioned this pull request Oct 6, 2022
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

Successfully merging this pull request may close these issues.

Regex replaceAll bug with ^ character
3 participants