Here's the code:
pattern = re.compile(r'ea')
match = pattern.match('sea ea')
if match:
print match.group()
the result is null. But when I change the code to pattern = re.compile(r'sea')
, the output is "sea"
Could anyone give me an explanation?
p.s. Btw, What I want is to retrieve the "#{year}" from string "select * from records where year = #{year}", plz give me an usable regex. Thanks in advance!
Summary:
Thanks to ALL of u, I find it in the document of python with your instruction. since I can select only one most appropriate answer, I just give it to the one who answered most quickly. Thx again.