issue while matching special char '\' in regular expression using '\\'
Question: I have very simple python script to match some special characters like -,+,-,.
But Im not getting expected result while using regex \ to match a single '\'
char.

    
    
    import re
    pat = r'[-+*\\]'
    text = 'fdkjdfk\sdsdd'
    if re.search(pat,text):
       print re.search(pat,text).group()
    else:
       print "not found"
    

On running above code , it prints 'not found' It seems I am doing some mistake
here , any help appreciated !!!


Answer: `\` is an escape character.

Try escaping it:

    
    
    text = 'fdkjdfk\\sdsdd' 
    

