Skip to content

expr: Fix regex anchor matching behavior with REGEX_OPTION_SINGLELINE #7846

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

frendsick
Copy link
Contributor

The previously used REGEX_OPTION_NONE allowed anchors (^) and ($) to match across newlines.

New anchor behaviors:

  • ^ matches the start of the entire string (\A)
  • $ matches the end of the entire string (\Z)

The following is copied from the documentation comments of RegexOptions::REGEX_OPTION_SINGLELINE:

onig::flags::RegexOptions

pub const REGEX_OPTION_SINGLELINE: Self = REGEX_OPTION_SINGLELINE

─────────────────────────────────────────────────────────────────
`'^'` -> `'\A'`, `'$'` -> `'\Z'`

The previously used `REGEX_OPTION_NONE` allowed anchors (^) and ($) to match across newlines.

New anchor behaviors:
- `^` matches the start of the entire string (`\A`)
- `$` matches the end of the entire string (`\Z`)
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)

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.

1 participant