Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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()

('a',)

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

('abc',)

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 in Java by dante07 (13.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...