爬虫笔记(9/25)------正则表达式
来源:互联网 发布:淘宝哪家鞋子质量好 编辑:程序博客网 时间:2024/05/10 06:24
1.正则表达式常用函数
1)re.match(pattern,string,flag)#(正则表达式,源字符,可选参数对应的标志位)
2)全局匹配函数
import restring="apythonhellomypythonhispythonourpythonend"pattern=re.compile(".python.")#预编译result=pattern.findall(string)#找出符合模式的所有结果print(result)3)re.sub(pattern,rep,string,max)#(正则表达式,源字符,替换字符,最多替换次数)
实例:
正则表达式常用内容:
a.不能出现空格[^\s]*
b.以.com或者.cn结尾[.com|.cn]
c.任意的字母组合包括大小写[a-zA-Z]
d.匹配电子邮件\w+([.+-]\w+)*@\w+([.-]\w+)*\.\w+([.-]\w+)*
阅读全文
0 0
- 爬虫笔记(9/25)------正则表达式
- 爬虫学习笔记(三)——Re正则表达式
- 黑马程序员_温习 正则表达式 (个人笔记)摘要(正则表达式-----网页爬虫)
- (正则表达式)邮件地址爬虫
- 正则表达式(网页爬虫)
- 正则表达式-爬虫(四)
- 正则表达式(网页爬虫)
- Python爬虫学习笔记(1)-正则表达式
- Python爬虫入门笔记:正则表达式
- [笔记]python爬虫:正则表达式库re
- 黑马程序员-正则表达式(网页爬虫)
- Python爬虫入门(7):正则表达式
- Python爬虫入门(7):正则表达式
- Python爬虫基础-5(正则表达式)
- Python网络爬虫(3)正则表达式
- Python爬虫四(正则表达式)
- python爬虫(一) 正则表达式
- Python爬虫入门(7):正则表达式
- matlab里插值算法问题
- icacls: Windows命令行授权文件访问权限
- netvirt-DVR路由流表分析
- Android 录音声音分贝获取
- 泡澡...
- 爬虫笔记(9/25)------正则表达式
- Ubuntu 16.04 LTS安装sogou输入法
- unique-binary-search-trees-ii
- 1025. 反转链表 (25)--PAT乙级
- 学习之路-Hibernate延迟加载
- Valid Parentheses--LeetCode
- Android Apk解析
- Word Amalgamation(STL库的使用 + next_permutation)
- ROS Service的使用_Python