Skip to content
DuckDB community extension

urlpattern

WHATWG URLPattern API for matching and extracting components from URLs using pattern syntax

01 / SETUP

Install and load

Run these commands in a Haybarn SQL session. The extension is available from the community repository.

Haybarn 2.0.0 · SQL
INSTALL urlpattern FROM community;
LOAD urlpattern FROM community;

Using upstream DuckDB? Follow the maintainer’s installation instructions.

02 / QUERY

Usage example

Test if a URL matches a pattern

SQL
-- Test if a URL matches a pattern
SELECT urlpattern_test('https://example.com/users/:id', 'https://example.com/users/123');
-- true

-- Extract a named group from a URL
SELECT urlpattern_extract('https://example.com/users/:id', 'https://example.com/users/123', 'id');
-- '123'

-- Get full match results with all components
SELECT urlpattern_exec('/posts/:slug', '/posts/hello-world');
-- {matched: true, pathname: '/posts/hello-world', groups: {slug: 'hello-world'}, ...}

-- Use the URLPATTERN type for validated patterns
SELECT urlpattern_test(urlpattern('/api/:version/*'), '/api/v2/users/list');
-- true

Provided by teaguesterling. Not yet verified on Haybarn 2.0.0.

Sample data & setup

About this extension

The URLPattern extension implements the WHATWG URLPattern API for DuckDB, enabling powerful URL matching, extraction, parsing, and construction.

For full documentation, see duckdb-urlpattern.readthedocs.io.

Project overview from the community descriptor.

Documentation and resources

Project and build details
Repository
teaguesterling/duckdb_urlpattern
License
MIT
Maintainers
teaguesterling
Written in
C++
Build source
0e14b580454e
Build definition
Community descriptor