When I read about character classes in the previous mission I see that the “.” class has no backslash in front of it. However, in the solution to this problem, DQ uses a backslash r"[Pp]ython ([\d\.]+)"
Is the backslash optional or is it a typo in the previous mission ?
Hello @nicolas_mtl! I’m not sure which mission you’re talking about. I cannot see your code in any of the solutions.
However, to answer your question: the special symbol . (dot) matches any character (except new line) but if you want to match only the dot (as literal character) you have to escape it with a backslash. It’s also valid for other special symbols like $, ^ ecc. You can read more about it here.
You can remove the backslash in \. to . and r"[Pp]ython ([\d.]+)" should still work the same.
You can do a quick test on https://regex101.com/.
Mouseover your regex and it should say “x matches the character x literally” vs a wildcard outside character class [] which says “x matches any character (except for line terminators)”. You can further confirm this by inserting random characters after python (eg. python 3.a.3) and see that the . inside [] does not match extra a and is indeed not a wildcard.