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

Regular expressions Modifier: (?ims-ims:...) #Matching certain words case-insensitively #37113

Closed
Invalid-Username404 opened this issue Dec 5, 2024 · 2 comments · Fixed by #37119
Labels
Content:JS JavaScript docs good first issue A good issue for newcomers to get started with.

Comments

@Invalid-Username404
Copy link

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Modifier

What specific section or headline is this issue about?

Matching certain words case-insensitively

What information was incorrect, unhelpful, or incomplete?

const pattern = /(?:var|let|const) (?i:foo|bar)\b/i;

pattern.test("let foo;"); // true
pattern.test("const BAR = 1;"); // true
pattern.test("Let foo be a number"); // false

What did you expect to see?

The "-" after the first "?" is missing which turned into a non-capturing group.
const pattern = /(?-i:var|let|const) (?i:foo|bar)\b/i;

pattern.test("let foo;"); // true
pattern.test("const BAR = 1;"); // true
pattern.test("Let foo be a number"); // false

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@Invalid-Username404 Invalid-Username404 added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Dec 5, 2024
@github-actions github-actions bot added the Content:JS JavaScript docs label Dec 5, 2024
@Josh-Cena
Copy link
Member

Great job being the first to discover this typo (which I've noticed for a while but never fixed it)! However, my typo was because I added i to the flag list—we should remove that. The first group is actually intended to be a non-capturing group.

@Josh-Cena Josh-Cena added good first issue A good issue for newcomers to get started with. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Dec 6, 2024
@Invalid-Username404
Copy link
Author

Thank you for the clarification. I noticed some issues in the JavaScript reference and apologize for not reporting them.

@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Dec 6, 2024
@Josh-Cena Josh-Cena removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:JS JavaScript docs good first issue A good issue for newcomers to get started with.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants