Regular Expressions 101

Community Patterns

1...34567...901

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

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

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 - 2 months ago (Last modified 2 months ago)