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 - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -