python - 为什么我的正则表达式不起作用,它有一个“或”
问题描述
当我这样做时,我得到了预期,re.findall(r'applepast[ry|e]', s17)
但我无法理解为什么我需要在+
这里给予,因为我已经明确地给予e|ry
import re
s17 = 'find word that match applepastry, applepie or applepaste'
re.findall(r'applepast[ry|e]', s17)
我的出局
['applepastr', 'applepaste']
我的预期
['applepastry', 'applepaste']
解决方案
推荐阅读
- c# - 尝试运行 ASP .Net Core 2.1 Web 应用程序时出现错误 502.5
- linux - 为什么 linux 上的 monodevelop 只提供“任何 cpu”平台?
- arrays - 使用数组索引中的变量输出 $Error
- c++11 - 如何在保持字符的同时加宽标准字符串?
- angular - 尝试运行 composer-rest-server 时管理员未注册错误
- swift - Swift,访问表格视图的数据
- sas - 从 EG 服务器将 ODS 文件写入本地计算机
- c++ - “std_lib_facilities.h”显示错误
- django-models - 有没有办法订购序列化程序的返回?django 休息框架
- jquery - 表在已使用 jquery 更改的固定位置上保持相同的大小