Use re.finditer()
:
>>> s="111234"
>>> [m.group(0) for m in re.finditer(r"(\d)\1*", s)]
['111', '2', '3', '4']
More Related Contents:
- How t extract last part of a text in python [duplicate]
- How to understand regular expression with python?
- How to extract numbers from a string in Python?
- Speed up millions of regex replacements in Python 3
- Is there a simple way to remove multiple spaces in a string?
- How to correctly sort a string with a number inside? [duplicate]
- Split string on whitespace in Python [duplicate]
- Fast punctuation removal with pandas
- Remove all special characters, punctuation and spaces from string
- Python regex – r prefix
- How to input a regex in string.replace?
- Split a string at uppercase letters
- How can I do multiple substitutions using regex?
- Python regex match OR operator
- Find longest repetitive sequence in a string
- How to match any string from a list of strings in regular expressions in python?
- How to extract an IP address from an HTML string?
- Regex for existence of some words whose order doesn’t matter
- How would I get everything before a : in a string Python
- Python regex: splitting on pattern match that is an empty string
- Mass string replace in python?
- Remove duplicate chars using regex?
- How to remove symbols from a string with Python? [duplicate]
- How can I split this comma-delimited string in Python? [duplicate]
- Remove Sub String by using Python
- FutureWarning: The default value of regex will change from True to False in a future version
- How do I verify that a string only contains letters, numbers, underscores and dashes? [duplicate]
- How to use str.contains() with multiple expressions in pandas dataframes
- Splitting a math expression string into tokens in Python
- Adding characters after a certain word in Python using regex