Repository navigation
fix: support d, s, u, and v flags in regexp/regexp - #16543
Open
rajanpanth wants to merge 1 commit into
Open
rajanpanth wants to merge 1 commit into
rajanpanth wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request:
adds the
d,s,u, andvflags to the flags accepted byregexp/regexp. The regular expression only acceptedimgy, so a regular expression string using any other standard flag was not recognized:uandywere added in ES2015,sin ES2018,din ES2022, andvin ES2024.updates the documented regular expression in
lib/regexp.jsto match.adds tests to
regexp/regexpfor strings with each newly accepted flag, and a test toutils/regexp-from-stringchecking that each flag supported by the current environment round-trips.Related Issues
None.
Questions
The pattern still accepts a repeated flag (e.g.,
/beep/gg), as it did before forimgy;reFromStringthen throws when constructing the regular expression. I left this behavior unchanged to keep the change focused. Happy to tighten the pattern to reject repeated flags if preferred.Other
regexp/regexp(e.g.,utils/regexp-from-stringandassert/is-regexp-string) pick up the change without modification, and their existing tests pass.reFromStringnow throws when constructing the regular expression, rather than returningnull. For this reason, the newutils/regexp-from-stringtest only checks flags thatnew RegExp()accepts in the current environment.regexp/regexptests fail ondevelop(6 assertions in each oftest.main.jsandtest.regexp.js), as does the newutils/regexp-from-stringtest.regexp/regexp,utils/regexp-from-string, andassert/is-regexp-stringdirectly with Node.js andtapeon Windows (asmakewas not available in my environment); I did not run the full repository lint pipeline locally.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written with the help of Claude Code, which found the issue, drafted the change and tests, and ran the verification described above. I reviewed the changes and the test results before submitting.
@stdlib-js/reviewers
🤖 Generated with Claude Code