unexpected end of regular expression
I want to get only the file name with extension from the path: C:\\Users\\anandada\\workspace\\MyTestProject\\src\\OpenTest.c The statement below, fileName = re.match("[^\\]*.c$", fileName) gives error: unexpected end of regular expression I am using python 3.3.2 You need to double the doubled escapes again , or use a raw string instead: fileName = re.match("[^\\\\]*.c$",fileName) or fileName = re.match(r"[^\\]*.c$",fileName) otherwise first Python, then the regular expression compiler will interpret those backslashes, resulting in the ] being escaped: >>> print("[^\\]*.c$") '[^\]*.c$' Also