Using the re library my problem is in this line
x = re.match("([A-Z]:|home∼|\.\.?)\\", txt)
Im trying to get a match with a disk "E:", "home∼", or a parent folder ".." followed by a backslash
The error goes as following:
Exception has occurred: error bad escape (end of pattern) at position 20
Am i doing something wrong? I think i´m doing something really dumb and don't realise it
r"([A-Z]:|home∼|\.\.?)\\"- note therat the start. Otherwise the actual string value has only a single backslash at the end.\\in a string literal gives you a\in your string. A\on its own in a regular expression is a bad escape because the regex engine doesn't know what you're trying to escape with it.