python - regex101.com 表达式在实际 python 中不起作用
问题描述
我需要一个正则表达式来在一串数字中找到确切数量的匹配数字。(例如,“正好三个重复数字”)
在regex101 我得到了一个正常工作的正则表达式 (^|(.)(?!\2))(\d)\3{2}(?!\3)
但是当我在 python3.6 shell 中尝试它时,它失败了,match
返回 None:
import re
three_char_re = re.compile("(^|(.)(?!\2))(\d)\3{2}(?!\3)")
print(three_char_re.match("14551114"))
我的 python 环境和 regex101 之间是否有一些默认标志不同?我找不到正则表达式或测试输入的差异。
解决方案
推荐阅读
- python - 如何从列表到排序的元组?
- powerbi - 如何在 PowerBI 中为每个特定类别编写前一天比率的折线图
- c - 如何在c中的结构中使用if条件
- javascript - 不能在 AR 会话后面使用共享对话框
- .net - 技能端点不接受有效的签名请求
- c - 打印 ASCII 代码字符的程序有问题吗?
- c# - 如何执行依赖注入以在 C# 中配置扩展方法?
- python - Python 从文件中加载 json。期望值:第 1 行第 1 列(字符 0)错误
- javascript - 如何在本机反应中从 Firestore 读取字段数据?
- apache-spark - Spark 流式查找每个窗口的每个键的比率