- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 repeating character classes used in Python regular expression?
A character class followed by operators like '?', '*' or '+' are called repeating character classes.
If you repeat a character class by using the '?', '*' or '+' operators, you will repeat the entire character class, and not just the character that it matched. The regex '[0-9]+' can match '579' as well as '333'. If you want to repeat the matched character, rather than the class, you will need to use backreferences. '([0- 9])\1+' will match '333' but not “579”. When applied to the string “922226”, it will match '2222' in the middle of this string. If you do not want that, you need to use lookahead and lookbehind.
- Related Articles
- What are character classes or character sets used in Python regular expression?
- What are metacharacters inside character classes used in Python regular expression?
- What are negated character classes that are used in Python regular expressions?
- How to write Python Regular Expression find repeating digits in a number?
- Explain character classes in Java regular expressions
- What are regular expression repetition cases in Python?
- What Python regular expression can be used in place of string.replace?
- How to match a nonwhitespace character in python using Regular Expression?
- How to match a single character in python using Regular Expression?
- How to match any one uppercase character in python using Regular Expression?
- How to match any non-digit character in Python using Regular Expression?
- What is a regular expression in Python?
- What does “?:” mean in a Python regular expression?
- Regular Expression Modifiers in Python
- Regular Expression Patterns in Python

Advertisements