topic description
as the title, I am a beginner. I have just learned regular expressions. If I want to know the specific use of periods, I casually make up a simple piece of code. Then it is found that the matching expressions are. , (.) and [.] * are matching results are quite different. I would like to ask the specific difference between these three and why there is such a result.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
import re
s = "nhellonmy name isnBob"
r = re.findall (". *", s)
print (r)
r = re.findall ("(.) *", s)
r = re.findall ("[.] *", s)
Code results
the above code, when the match is. *, the result is like this.
(.)*
[.]*
I don"t quite understand the latter two. I hope you can help me solve it. Thank you.
in addition, I think the meaning of the period in the regular expression is to match characters other than newline characters, so in the above code, why do you match an empty character""after matching the last character" b"?