Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
到目前为止,我有以下正则表达式与常规域匹配,但与带下划线的域不匹配。示例:_tcp._sip.45.example.com。任何帮助将不胜感激。
(?P<name>([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6})
\b((xn--)?[a-z0-9\w]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b
试试这个,或者坚持你的,基本上 \w 是你为下划线添加的。