Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (12.7k points)
Can anyone tell me, What does this group() method in regular expressions means in python?

1 Answer

0 votes
by (26.4k points)

For re details counsel this doc. For your situation: 

group(0) represents all coordinated with string, subsequently abc, that is 3 gatherings a, b and c 

group(i) represents i'th bunch, and referring to documentation

If a group matches multiple times, only the last match is accessible

thus group(1) represents the last match, c 

Your + is deciphered as gathering redundancy, in the event that you need to repeat [abc] inside the gathering, move + into brackets:

>>> re.match("([abc])", "abc").groups()


>>> re.match("([abc]+)", "abc").groups()


Wanna become a Python expert? Come and join the python certification course and get certified.

For more details, do check out the below video tutorial...

Related questions

0 votes
1 answer
0 votes
1 answer
asked Nov 12, 2020 in Python by ashely (50.2k points)
0 votes
1 answer
asked Mar 22, 2021 in Java by dante07 (13.1k points)

Browse Categories