Tuesday, April 24, 2012

what is the specific re for this

I'm trying to use python re to find a set of the same letter or number repeated a specific number of times. (.) works just fine for identifying what will be repeated, but I cannot find how to keep it from just repeating different characters. here is what I have:



re.search(r'(.){n}', str)


so for example it would match 9999 from 99997 if n = 4, but not if n = 3.

thanks





No comments:

Post a Comment