python - Python regex - 在 regex101.com 中使用 re.findall() v/s clean 组进行零长度匹配
问题描述
为什么我在使用时得到零长度匹配,re.findall()
而在评估 regex101 上的模式时却没有得到任何匹配:
text:
Relatie f. dsgfsdg\n
Factuur 26427432\n
Machtiging 436346y435643yerhg\n
IncassantID 4ty43y643erhgerh\n
Onderwerp Uw factuur\n
Datum 25 mei 2014\n
本地(jupyter 笔记本):
re.findall('(Factuur)(\s+)(\d+)|(Datum)(\s+)(\d+\s+\w+\s+\d+)', content)
[('Factuur', ' ', '2423828', '', '', ''),
('', '', '', 'Datum', ' ', '25 mei 2014')]
正则表达式101.com:
r"(Factuur)(\s+)(\d+)|(Datum)(\s+)(\d+\s+\w+\s+\d+)"
解决方案
推荐阅读
- github - GitHub Actions:在合并后找到 Pull Request 并使用 Action 对其进行评论
- java - 在一些 Android 设备上升级数据库时抛出 SQLiteException 而没有消息
- django - 没有显示项目列表时面临的 Django 错误
- python - 如何检索字典中的列表?
- r - 如何使用 usethis 在谷歌云平台上增加我的 R 包的版本?
- javascript - 全屏菜单覆盖:如何使其淡入淡出?
- ios - 使用 AVAudioEngine 从外部 MIDI 垫播放声音
- c - 堆栈上的临时数据是否始终预设?
- javascript - 如何订购由仅包含一个对象的 firebase 集合
- php - 在共享主机上使用微风和 laratrust 部署 laravel 8