On May 19, 4:54 am, [EMAIL PROTECTED] wrote:
> Hello,
>
<snip code example scraping a QOTD from www.mcgyver.com>
>
> print out
> **************

Since you have no control over spacing and line breaks in the input,
you can reformat using the textwrap module.  First replace all "\n"s
with " ", then use re.sub to replace multiple spaces with a single
space, then call textwrap.fill to reformat the line into lines up to
'n' characters long (I chose 50 in the sample below, but you can
choose any line length you like).

out = match.findall(html)
out = out[0].replace("\n"," ")
out = re.sub("\s+"," ",out)

print textwrap.fill(out,50)


-- Paul
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to