Steven D'Aprano wrote:
def strip_blank_lines(lines):
for line in lines:
if not line.isspace():
yield line
text = ''.join(strip_blank_lines(lines.split('\n')))
The final version I have is:
def strip_blank_lines(text):
result = []
for line in text.split('\n'):
> On 08/11/10 06:21, Andreas Tawn wrote:
> >> I'm looking for a regex (or other solution, as long as it's quick!)
> >> that could be used to strip out lines made up entirely of
> whitespace.
> >>
> >> eg:
> >>
> >> 'x\n \t \n\ny' -> 'x\ny'
> >
> > for line in lines:
> > if not line.strip():
On Wed, 11 Aug 2010 12:13:29 +0100, Chris Withers wrote:
> Hi All,
>
> I'm looking for a regex (or other solution, as long as it's quick!) that
> could be used to strip out lines made up entirely of whitespace.
def strip_blank_lines(lines):
for line in lines:
if not line.isspace():
On 08/11/10 06:21, Andreas Tawn wrote:
I'm looking for a regex (or other solution, as long as it's quick!)
that could be used to strip out lines made up entirely of whitespace.
eg:
'x\n \t \n\ny' -> 'x\ny'
for line in lines:
if not line.strip():
continue
doStuff(line)
No
> Hi All,
>
> I'm looking for a regex (or other solution, as long as it's quick!)
> that
> could be used to strip out lines made up entirely of whitespace.
>
> eg:
>
> 'x\n \t \n\ny' -> 'x\ny'
>
> Does anyone have one handy?
>
> cheers,
>
> Chris
for line in lines:
if not line.strip():
Hi All,
I'm looking for a regex (or other solution, as long as it's quick!) that
could be used to strip out lines made up entirely of whitespace.
eg:
'x\n \t \n\ny' -> 'x\ny'
Does anyone have one handy?
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting