Newbie question about Re

Cezar Ionescu ionescu at
Tue Aug 24 10:09:10 EDT 1999

MB wrote:

> I just want to split a string of n x (p characters) into a list of
> p_length strings using the Re module
> Example: Assume p=5 the string '12345ABCDE12345IJKLM' must be split in
> ['12345','ABCDE','12345','IJKLM'']
> The way I  find is to make a replace before splitting:

I'm not sure I understand. why use re? Why not:

str =  '12345ABCDE12345IJKLM'
l = []
i = 0

while i < len(str):
	i = i+5

This gives the list you wanted.

All the best,

More information about the Python-list mailing list