【发布时间】:2021-04-21 23:23:43
【问题描述】:
我希望在 python 中创建一个正则表达式,以便仅从本文底部的 URL 集中提取域。在应用Series.str.extract() 之前,我一直在使用https://regexr.com/ 来测试我的正则表达式。到目前为止,我已经能够非常接近,但看起来第一个字符(www 中的第一个'w',其中包含一个)没有被捕获。我到目前为止的正则表达式是这样的:
[^\/\/](\w*.\w*.com|\w*.\w*.org|\w*.\w*.cc|\w*.\w*.ly)
如何将其从 http://css-cursor.techstream.org 修改为仅 css-cursor.techstream.org
'https://www.amazon.com/Technology-Ventures-Enterprise-Thomas-Byers/dp/0073523429',
'http://www.interactivedynamicvideo.com/',
'http://www.nytimes.com/2007/11/07/movies/07stein.html?_r=0',
'http://evonomics.com/advertising-cannot-maintain-internet-heres-solution/',
'HTTPS://github.com/keppel/pinn',
'Http://phys.org/news/2015-09-scale-solar-youve.html',
'https://iot.seeed.cc',
'http://www.bfilipek.com/2016/04/custom-deleters-for-c-smart-pointers.html',
'http://beta.crowdfireapp.com/?beta=agnipath',
'https://www.valid.ly?param',
'http://css-cursor.techstream.org'
【问题讨论】: