首页 > 解决方案 > 正则表达式 r.match 在列表中搜索

问题描述

正则表达式:在列表中搜索

filter(r.match, list)

在这篇文章中有 r.match,什么是r.match.

我的理解是它r代表 re.compile() 并返回一个模式。但是深入研究https://docs.python.org/3/library/re.html#re.compile,只有 Pattern.match() 方法吗?没有模式.匹配..

标签: pythonpython-3.xregex

解决方案


不,r是代码前面的编译模式。就像是

import re
r = re.compile(r'hello')

推荐阅读