python - Why the below piece of regular expression code is returning comma(,) -


please let me know why following piece of code giving below result

>>> pattern = re.compile(r'[!#$%&()*+-.]') >>> pattern.findall("a,b") [','] 

there no comma(,) symbol in re.compile method, why matching comma also?

[+-.] single character in range + (ascii 43) . (ascii 46).

between 2 characters find , (ascii 44) , - (ascii 45).

i guess wanted \- instead of -.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - How can I echo out this array? -

javascript - IE11 incompatibility with jQuery's 'readonly'? -