Need help in text operation to add as mail body

This is the place for queries that don't fit in any of the other categories.

Need help in text operation to add as mail body

Postby idy » Fri Mar 01, 2013 5:50 am

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
idy
 
Posts: 1
Joined: Thu Feb 28, 2013 7:51 pm

Re: Need help in text operation to add as mail body

Postby stranac » Fri Mar 01, 2013 8:59 am

There are more than one way to do this:
  • loop through the string. If you run into 'XYC.', start a new line
  • find all occurrences of 'XYC.' and take the matching slices as lines
  • split on 'XYC.', and add it back in
I think the last one is the simplest option, at least in the amount of code it would take.
Give one of these approaches a try, and let us know if you run into problems.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1209
Joined: Thu Feb 07, 2013 3:42 pm


Return to General Coding Help

Who is online

Users browsing this forum: W3C [Linkcheck] and 4 guests