Jul-21-2022, 01:29 PM
Yes I understand, but there's also another difference: you've add the "r" in front of the string to declare a "regular expression" whereas in my case I'm using a variale: how can I use a variable or how can I declare the variable as a regular expression?
path = 'D:\My Directory1\bin' Var = r''+ path #Var = r'' + str(path) print("using replace", Var.replace('\\', '/')) print("using replace with raw string", path.replace(r"\ "[0], "/")) print("using regex", re.sub('\\\\', '/', path))(obviously it does not work because of \b as it has ever been sugested)