正则表达式
岚清子
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【Python】正则表达式中的贪婪匹配与非贪婪匹配
前言. :匹配除 “\n” 之外的任何单个字符*:匹配0个或多个字符.*匹配任意长度的任意字符贪婪匹配import reregex = ".*(b+).*"string = "abbbba"res = re.match(regex, string)print(res.group(1))>>> b分析:.*:默认匹配尽可能多的字符.*(b+).*:保证字符b出现至少一次的条件下,.*尽可能多的匹配任意字符所以,输出:b非贪婪匹配import原创 2020-06-25 15:59:31 · 614 阅读 · 0 评论 -
【Python】正则表达式快速入门(re模块的使用)【转载】
原文链接:https://morvanzhou.github.io/tutorials/python-basic/basic/13-10-regular-expression/一、简单的匹配正则表达式无非就是在做这么一回事. 在文字中找到特定的内容, 比如下面的内容. 我们在 “dog runs to cat” 这句话中寻找是否存在 “cat” 或者 “bird”.# matching stringpattern1 = "cat"pattern2 = "bird"string = "dog .转载 2020-06-23 21:56:02 · 191 阅读 · 0 评论
分享