Skip to content
Create a gist now

Instantly share code, notes, and snippets.

User Domain Multiline Regex
((\w|\d)+) # Captures the Username which can be a word or digit (will require validation)
\s # separate domain by a space
( # capture the domain
( # Capture either a multipart domain (subsubdomain.subdomain.domain)
((?<=.).*.(\w|\d)+) # do a negative lookbehind to see if we have a subdomain and a capture anything (.*) for the subdomain up to the space
| # or a singular domain (domain)
(?<=\s)(\w|\d)+ # use a negative lookbehind to find a space that separates the username
. # Separate the domain
(\w+(?<=\w+).\w+) #Do a negative lookbehind to check for multipart subdomain
\w+ # default to (single tld)
) # look for either a multipart tld ( or a regular tld (.com)
$ #Start at the end of the line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.