+ 12

I do not understand why it must be exactly 4 characters and what is the concrete benefit of "^" and "
quot;?

https://code.sololearn.com/cGBKbG9Yt1oF/?ref=app

24th Mar 2018, 12:55 AM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
2 Respuestas
+ 6
Your ^g forces the first character of the string to be g in order to match. Your y$ forces the last character of the string to be y. Since you only allow two other characters between the g and y, it can only be matched by 4 character strings. r"^....
quot; matches any string that contains exactly 4 characters.
24th Mar 2018, 1:44 AM
John Wells
John Wells - avatar
+ 2
It must be 4 characters because you put three definite character and then one unknown between r and y To have an unlimited amount of characters in between them use .*
24th Mar 2018, 1:13 AM
Ariela
Ariela - avatar