python equiv of perl's split?

Laura Creighton lac at strakt.com
Mon Jan 13 17:03:00 CET 2003


> >>>> import re re.split("(:)", "test:one:two:three")
> > ['test', ':', 'one', ':', 'two', ':', 'three']
> 
> Doh!  I didn't realize there was a split in the 're' module, I was
> using the one from the 'string' module.  

Just FYI:
If your python is recent (2.something) you didn't need to import
the string module, because  there are now string methods. It is there
for backwards compatibility.

Laura Creighton





More information about the Python-list mailing list