import re
str = r'\path\file.ext'
m = re.search(r'\\(.+?)\.ext', str)
print(m.groups()[0])

とやると、
path\file
が表示される
期待してるのはfileだけなのに
\の扱いがよく判らん