On Feb 28, 5:50 pm, "Ryan K" <[EMAIL PROTECTED]> wrote: > On Feb 28, 8:27 pm, [EMAIL PROTECTED] wrote: > > > Try: > > > import re > > sample_text = """Personal firewall software may warn about the > > connection IDLE makes to its subprocess using this computer's internal > > loopback interface. This connection is not visible on any external > > interface and no data is sent to or received from the Internet.""" > > > # assume 24 is sufficiently wide: > > > lines = map(lambda x: x.rstrip(), > > re.findall(r'.{1,24}(?:(?<=\S)\s|$)', sample_text.replace("\n", " "))) > > > print "\n".join(lines) > > > -- > > Hope this helps, > > Steven > > That works great but I need to replace the newlines with 24-(the index > of the \n) spaces. >
Just left-justify to the appropriate width with the the padding character you wanted: equally_long_lines = map(lambda x: x.ljust(24, ' '), lines) print "\n".join(equally_long_lines) -- Hope this helps, Steven -- http://mail.python.org/mailman/listinfo/python-list