Regular Expressions 101

Community Patterns

1...45678...902

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
(https?:\/\/)?bitbucket\.org\/(?<author>[\w-]+)\/(?<repo>[\w-]+)\/?(src\/)?(?<branch>[\w-]+)?
/
gm

Description

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

Submitted by Xain - 3 months ago