# What are regular expression repetition cases in Python?

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

Things become more interesting when you use + and * to specify repetition in the pattern

• + -- 1 or more occurrences of the pattern to its left, e.g. 'i+' = one or more i's

• * -- 0 or more occurrences of the pattern to its left

• ? -- match 0 or 1 occurrences of the pattern to its left

## Example

The following code answers the question above

import re
s = "sheeeeeeeeple"
match = re.search(r"he+", s)
print match.group()

## Output

This gives the output

heeeeeeee

Updated on 18-Feb-2020 10:39:51