Parsing/Splitting Line

Fredrik Lundh fredrik at pythonware.com
Wed Nov 22 04:06:40 EST 2006


Noah Rawlins wrote:


> I'm a nut for regular expressions and obfuscation...
> 
> import re
> def splitline(line, size=4):
>      return re.findall(r'.{%d}' % size, line)
> 
>  >>> splitline("helloiamsuperman")
> ['hell', 'oiam', 'supe', 'rman']

there are laws against such use of regular expressions in certain 
jurisdictions.

</F>




More information about the Python-list mailing list