Re: How to prevent re.split() from removing part of string

2009-12-01 Thread Jeremy
On Nov 30, 5:24 pm, MRAB wrote: > Jeremy wrote: > > I am using re.split to... well, split a string into sections.  I want > > to split when, following a new line, there are 4 or fewer spaces.  The > > pattern I use is: > > >         sections = re.split('\n\s{,4}[^\s]', lineoftext) > > > This split

Re: How to prevent re.split() from removing part of string

2009-11-30 Thread MRAB
Jeremy wrote: I am using re.split to... well, split a string into sections. I want to split when, following a new line, there are 4 or fewer spaces. The pattern I use is: sections = re.split('\n\s{,4}[^\s]', lineoftext) This splits appropriately but I lose the character matched by [^s