From 048ecbb9281e728f420299bb1506a82b7b528bf8 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Fri, 23 Aug 2024 18:10:49 +0100 Subject: [PATCH 1/2] Make meaning of parentheses for regex explicit in URL Pattern API --- files/en-us/web/api/url_pattern_api/index.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/files/en-us/web/api/url_pattern_api/index.md b/files/en-us/web/api/url_pattern_api/index.md index ab180c1c9bdf1ba..a36e0f8b522eaab 100644 --- a/files/en-us/web/api/url_pattern_api/index.md +++ b/files/en-us/web/api/url_pattern_api/index.md @@ -27,7 +27,8 @@ can contain: - Non-capturing groups (`/books{/old}?`) which make parts of a pattern optional or be matched multiple times. - {{jsxref("RegExp")}} groups (`/books/(\\d+)`) which make arbitrarily complex - regex matches with a few [limitations](#regex_matchers_limitations). + regex matches with a few [limitations](#regex_matchers_limitations). _Note the + parentheses define the contents as a regex and are not part of the regex._ You can find details about the syntax in the [pattern syntax](#pattern_syntax) section below. @@ -79,9 +80,9 @@ match the shortest possible string. ### Regex matchers Instead of using the default match rules for a group, you can use a regex for -each group. This regex defines the matching rules for the group. Below is an -example of a regex matcher on a named group that constrains the group to only -match if it contains one or more digits: +each group by including a regex in parentheses. This regex defines the matching +rules for the group. Below is an example of a regex matcher on a named group +that constrains the group to only match if it contains one or more digits: ```js const pattern = new URLPattern("/books/:id(\\d+)", "https://example.com"); From 2427134a7f6316210a94ce1e7a932a24d1a8a9b0 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Sat, 24 Aug 2024 02:30:37 +0900 Subject: [PATCH 2/2] Update files/en-us/web/api/url_pattern_api/index.md --- files/en-us/web/api/url_pattern_api/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/en-us/web/api/url_pattern_api/index.md b/files/en-us/web/api/url_pattern_api/index.md index a36e0f8b522eaab..27f4d12fa838f41 100644 --- a/files/en-us/web/api/url_pattern_api/index.md +++ b/files/en-us/web/api/url_pattern_api/index.md @@ -27,8 +27,8 @@ can contain: - Non-capturing groups (`/books{/old}?`) which make parts of a pattern optional or be matched multiple times. - {{jsxref("RegExp")}} groups (`/books/(\\d+)`) which make arbitrarily complex - regex matches with a few [limitations](#regex_matchers_limitations). _Note the - parentheses define the contents as a regex and are not part of the regex._ + regex matches with a few [limitations](#regex_matchers_limitations). _Note that the + parentheses are not part of the regex but instead define their contents as a regex._ You can find details about the syntax in the [pattern syntax](#pattern_syntax) section below.