The following code using regex matches the file extension in the given file name.
Example
import re
result = re.search('.doc$', '87654_3.doc')
print result.group()Output
This gives the output
.doc
The following code using regex matches the file extension in the given file name.
import re
result = re.search('.doc$', '87654_3.doc')
print result.group()This gives the output
.doc