public
Created

User Domain Multiline Regex

  • Download Gist
userdomainmultilineregex.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Usage:
 
<username><space><subdomain>*<.><domain><.><TLD>
 
((\w|\d)+)\s((((?<=.).*.(\w|\d)+)|(?<=\s)(\w|\d)+).(\w+(?<=\w+).\w+)|\w+)$
 
((\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 (.co.uk) or a regular tld (.com)
$ #Start at the end of the line

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.