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
Post a Comment