Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2020-02-28 12:12
Flavor·ECMAScript (JavaScript)

/
^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)?(\/)?([a-z]{2}-[a-z]{2})
/
gmi
Open regex in editor

Description

Regex that captures both domain and locale for a given url. Eg: https://sumup.com/en-en/welcome

matches https://sumup.com/en-en

Submitted by anonymous