0
Im really neading for help guys, plz
Can anybody explain me how the coding below outputs ananac? import re a = "applebananacocoa" b = re.match('^a[a-p]*leb([a-n]*)',a) print(b.group(1))
4 Answers
+ 4
[a-p]* match 0 or more characters that is between a to p.
([a-n]*) match 0 or more characters that is between a to n. And it's grouped by parentheses.
a [a-p]* leb ([a-n]*)
a pp leb ananac
Regex is matched and ananac is grouped.
+ 3
It prints the first group of the regex match.
A group is the match that is quoted with parentheses.
0
Can you also explain what print(b.group(1)) is?
0
Thanks alot! Have a nice day