3 ms·
I tend to write such code without comments (using some pseudo-language): Protocol = 'https?://' Subdomain = '\w+' Domain = '[-\w]+' TLD = 'co
by Someone 13y ago
I tend to write such code without comments (using some pseudo-language):
Protocol = 'https?://'
Subdomain = '\w+'
Domain = '[-\w]+'
TLD = 'com|org'
Re = WholeTextMatches(
Protocol + Optional( Subdomain + '.')
+ Capture(Domain) + TLD)
Typically, I wouldn't go that far, but storing separate parts into well-named strings before assembling the entire regex, IMO, makes things much more readable.