import re
regex = r"\\{2,}"
test_str = r"%Software\\Policies\\\\Microsoft\\Windows\\Safer\\CodeIdentifiers\\0\\Hashes\\"
	
 
subst = r"\\"
result = re.sub(regex, subst, test_str,0)
 
if result:
    print (result)# your code goes here