URLPattern: hasRegExpGroups property

Baseline 2025
Newly available

Since September 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Note: This feature is available in Web Workers.

The hasRegExpGroups read-only property of the URLPattern interface is a boolean indicating whether or not any of the URLPattern components contain regular expression capturing groups.

You can use the hasRegExpGroups property to check if a URLPattern object is usable with certain web platform APIs which do not allow regular expression capturing groups. For example:

  • The match directive in the Use-As-Dictionary HTTP header prohibits regular expression capturing groups, as well as
  • the urlPattern condition when adding static routes using the InstallEvent.addRoutes() method.

Value

A boolean.

Examples

Using hasRegExpGroups

In the following example, a URLPattern object is used with a group delimiter containing named capturing groups called "id" and "title". The hasRegExpGroups property returns true in this case.

js
const pattern = new URLPattern({ pathname: "/blog/:id(\\d+){-:title}?" });
console.log(pattern.hasRegExpGroups); // true
const result = pattern.exec({ pathname: "/blog/123-some-article" });
console.log(result.pathname.groups); // {id: '123', title: 'some-article'}

It also works with anonymous capturing groups.

js
const pattern = new URLPattern({ pathname: "/blog/(\\d+)" });
console.log(pattern.hasRegExpGroups); // true
const result = pattern.exec({ pathname: "/blog/123" });
console.log(result.pathname.groups); // {0: '123'}

For other non-capturing groups, for example when using wildcard tokes (*), hasRegExpGroups will return false.

js
const pattern = new URLPattern({ pathname: "/blog/*" });
console.log(pattern.hasRegExpGroups); // false
const result = pattern.exec({ pathname: "/blog/123" });
console.log(result.pathname.groups); // {0: '123'}

Specifications

Specification
URL Pattern
# dom-urlpattern-hasregexpgroups

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
hasRegExpGroups
Chrome – Full support
Chrome 122 (Release date: 2024-02-20)
footnote Full support
Edge – Full support
Edge 122 (Release date: 2024-02-23)
footnote Full support
Firefox – Full support
Firefox 142 (Release date: 2025-08-19)
footnote Full support
Opera – Full support
Opera 108 (Release date: 2024-03-05)
footnote Full support
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Chrome Android – Full support
Chrome Android 122 (Release date: 2024-02-20)
footnote Full support
Firefox for Android – Full support
Firefox for Android 142 (Release date: 2025-08-19)
footnote Full support
Opera Android – Full support
Opera Android 81 (Release date: 2024-03-14)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support
Samsung Internet – Full support
Samsung Internet 26 (Release date: 2024-06-07)
footnote Full support
WebView Android – Full support
WebView Android 122 (Release date: 2024-02-20)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26 (Release date: 2025-09-15)
footnote Full support
Bun – Full support
Bun 1.3.4 (Release date: 2025-12-07)
footnote Full support
Deno – Full support
Deno 1.46 (Release date: 2024-08-22)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support