标签: python regex
如果我想匹配以 at 结尾的单词,并且使用。{1,2} 来指定 at之前可以包含1个或2个字符,如何排除空白字符?
此代码
atRegex = re.compile(r'.{1,2}at') atRegex.findall('The cat in the hat sat on the flat mat.)
将返回
[' cat', ' hat', ' sat', 'flat', ' mat']
我可以以某种方式将我自己的不包含空格字符的类(例如[^])合并到代码中吗?