Question

So far I've got the following regex that matches against regular domains but not domains with underscores. Example: _tcp._sip.45.example.com. Any help would be greatly appreciated.

(?P<name>([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6})
Was it helpful?

Solution

\b((xn--)?[a-z0-9\w]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b 

try this one, or stick with yours, basicaly \w is what you add for underscore.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top