+ 1
What does r"\w" mean and how do backslashes work in raw strings? Can I use another letter apart from w?
I was trying to solve the code challenge for metacharacters and I wasn't getting it. Looking at the solution I saw that "\w" was used but I don't get it. In the previous classes, I just used r"[A-Z][0-9]" and it worked so I'm wondering why it's different now.
4 odpowiedzi
+ 4
"[A-Z][0-9]" matches capital alphabet followed by a digit.
\w (word character) matches any single letter, number or underscore (same as [a-zA-Z0-9_]).
+ 2
Thank you for this Jayakrishna 🇮🇳 . If I can do it the way you have done in your example then what is the need for metacharacters like *,+ and ? ?
+ 2
*, +,?, {m, n} are repetition characters.
* for 0 or more repeated...
+ for 1 or more,
? 0 or 1
{m, n} atleast m, to n times at most.
+ 1
Ok, thank you sir.