Harvey Thomas <hst at empolis.co.uk> wrote: >import re >rex = re.compile('....', re.DOTALL) To work with any int n, change to one of these rex = re.compile('.{,%s}'%n, re.DOTALL) # keeps remainder segment rex = re.compile('.{%s}'%n, re.DOTALL) # discards remainder segment > >for substring in rex.findall(string): > <process substring> Huaiyu