text formatting question

I

idy

I have a text string of this format

Error = 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.1111111LOcation/user/data/INGE-FTYXYC.3333333LOcation/user/data/GETN-YUN'

I need to write this to mail body as with following format in multiple lines

XYC.12345455-LOcation/user/data/MYGLE-ING
XYC.23344566-LOcation/user/data/INGE-FTY
XYC.22334566LOcation/user/data/GETN-YUN
XYC.12345455LOcation/user/data/MYGLE-ING
XYC.1111111LOcation/user/data/INGE-FTY
XYC.3333333LOcation/user/data/GETN-YUN

Note (XYC is common for all the text , rest of the fields are not constant. Please help
 
C

Chris Angelico

Error = 'XYC.12345455LOcation/user/data/MYGLE-INGXYC.23344566LOcation/user/data/INGE-FTYXYC.22334566LOcation/user/data/GETN-YUNXYC.12345455LOcation/user/data/MYGLE-INGXYC.1111111LOcation/user/data/INGE-FTYXYC.3333333LOcation/user/data/GETN-YUN'

I need to write this to mail body as with following format in multiple lines

XYC.12345455-LOcation/user/data/MYGLE-ING
XYC.23344566-LOcation/user/data/INGE-FTY
XYC.22334566LOcation/user/data/GETN-YUN
XYC.12345455LOcation/user/data/MYGLE-ING
XYC.1111111LOcation/user/data/INGE-FTY
XYC.3333333LOcation/user/data/GETN-YUN

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
 
I

idy

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 !!!
 
I

idy

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 !!!
 
D

Dave Angel

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 ...
 
C

Chris Angelico

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.

Right. I should have mentioned that. Let's hope the OP is sufficiently
lucky as to have a separator uniqueness..


ChrisA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top