簡體   English   中英

Python正則表達式Findall

[英]Python Regular Expression Findall

我正在嘗試查找頂級域名信息。

如果我要搜索“ https://testwebsite.com.au/folders/viewforum.php?f=1556n ”,我只希望我的表達式查找“ https://testwebsite.com.au

我正在使用以下表達式:

urlRegex = re.compile(r'''( (https?|sftp|ftp|file)://[-a-zA-Z0-9+&@#/%?
           =~_|!:,.;'"*$()]*[a-zA-Z0-9+&@#/%=~_|]   )''', re.VERBOSE)

如果要嚴格和正確,請使用真實的URL解析器。 如果您正在尋找可用於99%的URL的快速而又骯臟的東西,該如何做:

urlRegex = re.compile(r'([a-zA-Z]+://[^/\s]+)')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM