

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- 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?
- What are regular expression repetition cases in Python?
- What Python regular expression can be used in place of string.replace?
- Explain character classes in Java regular expressions
- How to write Python Regular Expression find repeating digits in a number?
- How to escape any special character in Python regular expression?
- What is a regular expression in Python?
- How to match a single character in python using Regular Expression?
- How to match a nonwhitespace character in python using Regular Expression?
- What are the identity rules for regular expression?
- Regular Expression Examples in Python
- Regular Expression Modifiers in Python
- Regular Expression Patterns in Python
Advertisements