如何用PYTHON正则表达式来寻找URL
1、打开JUPYTER NOTEBOOK,新建一个空白的PY文档。

3、import re引入regular expression模块,然后才能运用相应的函数。

5、urlRegex = re.compile(r'[a-z]{4}://')urlRegex.search(r'http://www.heyheyhey.com')http可以用26个字母来代替,然后注明4个字母。

7、urlRegex = re.compile(r'''\w{4}://''')urlRegex.search(r'http://www.heyheyhey.com')\w也是可以表示字母的。

9、urlRegex = re.compile(r'''^http://$''')urlRegex.findall(r'http://www.heyheyhey.com*****https://www.heyheyhey.com')urlRegex = re.compile(r'''^http://$''')urlRegex.findall(r'http://')用^和$只能针对字符首尾,不太适用在这里。

11、urlRegex = re.compile(r'''http://|https://''')urlRegex.search(r'http://www.heyheyhey.com').group()urlRegex = re.compile(r'''http://|https://''')urlRegex.search(r'https://www.heyheyhey.com').group()用|字符表示或者。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:92
阅读量:27
阅读量:55
阅读量:68
阅读量:79