Test, validate and match regular expressions
Validates domain names including optional subdomains and punycode (xn--) internationalized domains. Each label must start and end with an alphanumeric character (no leading/trailing hyphens), is limited to ~63 characters, and the top-level domain must be at least two letters. With global/multiline flags, it can scan and validate domains across multiple lines, useful for form input validation and sanitizing user-submitted hostnames.