简单的正则表达式模式不匹配

时间:2016-03-02 17:42:11

标签: python regex

您好我正在编写一个需要一些正则表达式模式匹配的脚本,但我无法进行匹配。

这是一个MCVE:

import re

sourceString= 'Hi I want pizza for lunch'

patternObject=re.compile('pi.*');
match=patternObject.match(sourceString);

if match:
     print("the match is:",match.group())
else:
     print("no matches found!");

不幸的是,该程序的输出是"没有找到匹配项!"尽管"披萨吃午饭"是理想的输出。我理解错了什么?

0 个答案:

没有答案