Test, validate and match regular expressions
Matches a hostname and splits it into parts: group 1 captures the leading subdomain segment (letters, digits, hyphens), group 2 optionally captures a mid-level domain like '.example' (2-5 letters), and group 3 captures the final dot-prefixed TLD at end of line. Commonly used to strip the domain/TLD portion from a fully qualified domain, e.g., extracting 'www' from 'www.example.com'. The global and multiline flags allow processing many hostnames across multiple lines.