str = "a\b\c\dsdf\matchthis\erwe.txt"
The last folder name.
Match "matchthis"
>>> import re
>>> print re.match(r".*\\(.*)\\[^\\]*", r"a\b\c\dsdf\matchthis\erwe.txt").groups()
('matchthis',)
As @chrisaycock and @rafe-kettler pointed out. Use the x.split(r'\') if you can. It is way faster, readable and more pythonic. If you really need a regex then use one.
EDIT: Actually, os.path is best. Platform independent. unix/windows etc.
str.split("\\")or similar.