course content

Course Content

Python Basics: Regex Wizards

Group function 1/2Group function 1/2

The group() function in the re module in Python is used to extract a specific group from a match object returned by methods such as search() or finditer(). A group is created by enclosing a part of the regular expression in parentheses().


  1. import re;
  2. Define a text variable as "The cat in the hat.";
  3. Search for the first vowel value in the string using the following grammar: [aeiou];
  4. Print the output using the group() function.

Everything was clear?

Section 1. Chapter 5