KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've got a string that I'm trying to split into chunks based on blank lines. Given a string s , I thought I could do this: re.split('(?m)^\s*$', s) This works in some cases: >>> s = 'foo\nbar\n \nbaz' >>> re.split('(?m)^\s*$', s) ['foo\nbar\n', '\nbaz'] But it doesn't work if the line is completely empty: >>> s = 'foo\nbar\n\nbaz' >>> re.split('(?m)^\s*$', s) ['foo\nbar\n\nbaz'] What am I doing wrong? [python 2.5; no difference if I compile '^\s*$' with re.MULTILINE and use the compiled expression instead]
Tags (comma-separated)
Save Edits
Cancel