Community Patterns

Community Library Entry

1

Regular Expression
Created·2024-09-23 16:31
Updated·2024-09-23 16:37
Flavor·ECMAScript (JavaScript)

/
(https?:\/\/)?gitlab\.com\/(?<author>[\w-]+)\/(?<repo>[\w-]+)(\/-\/)?(tree\/)?(?<branch>[\w-]+)?
/
gm
Open regex in editor

Description

A regular expression for extracting the author, repository name, and optional branch from a GitLab repository or tree URL. Handles both HTTP(S) and direct GitLab links.

Submitted by Xain