I\'m just learning Python, and I can\'t seem to figure out regular expressions.
r1 = re.compile(\"$.pdf\")
if r1.match(\"spam.pdf\"):
print \'yes\'
else:
$
means "end of string". So, you need a regex like \.pdf$
to match:
.
), escaped because it is a special character in regular expressions.pdf
"Regular expressions go beyond languages, Python or others, so you should read some tutorials about them firstly. Consider regular-expressions.info. This is not a Python question actually, it is a fundamental regular expression question.