Regex for repeated character?

Leif K-Brooks eurleif at ecritters.biz
Thu Jun 16 03:18:25 EDT 2005


How do I make a regular expression which will match the same character
repeated one or more times, instead of matching repetitions of any
(possibly non-same) characters like ".+" does? In other words, I want a
pattern like this:

 >>> re.findall(".+", "foo") # not what I want
 ['foo']
 >>> re.findall("something", "foo") # what I want
 ['f', 'oo']



More information about the Python-list mailing list