RegularExpression: match and extract long domain

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


RegularExpression: match and extract long domain



I want to match and extract domain form strings,and I got an equation:


result = re.findall(r"(^((?!-))(xn--)?[a-z0-9][a-z0-9-_]{0,61}[a-z0-9]{0,1}.(xn--)?([a-z0-9-]{1,61}|[a-z0-9-]{1,30}.[a-z]{2,})$)", text)



It does well for domain like :


example.org
example.org.eu



but it cannot work for domain like :


sub_example.example.org.eu



so,I am asking for helping improving the equation.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?