def check(text):
pattern = re.compile(r'\\')
rv = re.match(pattern, text)
if rv:
return True
else:
return False
print check('\mi') # True
print check('\ni') # False
Actually,I want text contains '\' is illegal.
But '\n', '\b',etc, python treats them specially,so I can not match them out.
Any solutions?