text formatting question

Dave Angel davea at davea.name
Fri Mar 1 14:52:58 CET 2013


On 03/01/2013 02:08 AM, idy wrote:
> On Friday, March 1, 2013 12:23:41 PM UTC+5:30, Chris Angelico wrote:
>>
>>
>>>   <snip>
>>
>> You want to break the line immediately before the 'XYC'? That's quite
>> easy; the line break is a character like any other, and can be used in
>> a replace() call:
>>
>> formatted_error = Error.replace("XYC","\nXYC")
>>
>> If that's not the case, can you clarify what you need to do to divide it?
>>
>> Chris Angelico
>
> Chris,
>
> Thanks this works great !!!
>

The assumption Chris made is that the characters XYC do *not* appear 
anywhere else in each string.  if they do, then you need to write a spec 
as to what criteria you can count on for the data.

If somebody has mangled all those lines into one long string, it's quite 
likely that they CANNOT be reliably separated again.  Chris' suggestion 
is the most likely candidate, but ...
-- 
DaveA



More information about the Python-list mailing list