Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

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

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 - 5 years ago