- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are regular expression repetition cases in Python?
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
The following code answers the question above
import re s = "sheeeeeeeeple" match = re.search(r"he+", s) print match.group()
This gives the output
- What are repeating character classes used in Python regular expression?
- What is a regular expression in Python?
- What are metacharacters inside character classes used in Python regular expression?
- What are the identity rules for regular expression?
- Regular Expression Modifiers in Python
- Regular Expression Patterns in Python
- Regular Expression Examples in Python
- Regular Expression Matching in Python
- What are character classes or character sets used in Python regular expression?
- What is Raw String Notation in Python regular expression?
- What is regular expression in Java?
- Regular Expression in Python with Examples?
- What does “?:” mean in a Python regular expression?
- How regular expression modifiers work in Python?
- How regular expression grouping works in Python?