re.split() problem

Masayuki Takemura ICG04984 at nifty.com
Thu Sep 22 15:40:41 CEST 2005


Hi all. 

re.split() doesn't work as I intend.

My Python Version is  2.4.1
(#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32.

For example,

>>> r = re.compile('^$', re.MULTILINE)
>>> r.split('foo\nbar\n\nbaz')
['foo\nbar\n\nbaz']

but I expected ['foo\nbar\n', 'baz'].

This problem has been discussed following threads.

[ 852532 ] ^$ won't split on empty line
<http://sourceforge.net/tracker/index.php?func=detail&aid=852532&group_id=5470&atid=105470>

re.split on empty patterns
<http://thread.gmane.org/gmane.comp.python.devel/62231>

Will it be fixed in Python 2.4.2?

Regards,

--
Masayuki Takemura




More information about the Python-list mailing list