I have this string:
s = "mage('Images/mpins/pin5_Jul1.png', new"
This is my pattern:
patt_img = r'\w+.png'
Why does
re.findall(patt_img,s)
return
['pin5_Jul1.png']
but match returns None?
m = re.match(patt_img,s)
>>> type(m)
<type 'NoneType'>`
Because match matches only starting from the beginning of the string.
If zero or more characters at the beginning of string match the regular expression pattern, return a corresponding
MatchObjectinstance.If you want to locate a match anywhere in string, use
search()instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With