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))

15th Feb 2021, 12:59 AM
hostage Ghostsharon
hostage Ghostsharon - avatar
4 odpowiedzi
+ 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.
15th Feb 2021, 1:05 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 3
It prints the first group of the regex match. A group is the match that is quoted with parentheses.
15th Feb 2021, 5:42 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Can you also explain what print(b.group(1)) is?
15th Feb 2021, 1:14 AM
hostage Ghostsharon
hostage Ghostsharon - avatar
0
Thanks alot! Have a nice day
15th Feb 2021, 5:49 AM
hostage Ghostsharon
hostage Ghostsharon - avatar