Page 1 of 1

Finding to copy a value from a line to another line

Posted: Tue Feb 22, 2011 9:26 pm
by kr1
Sorry this looks a bit long, but most of it is example data...
I'm new to using regular expression so please excuse my ignorance if this is easy to people who are more familiar with this.

I'm not a programmer, I just have files of text data that I wish to interogate and manipulate.

I am try ing to use a find to then go on and potentailly copy some data from a string of text where the string of text preceeding the data I wish to copy is variable. The only constants are that the first three charachters (alpha) will be constant and the string of text will have the same amount of + signs within it.

I want to be able to populate the 6 numberics which appear after the fourth + sign onto each line below it, up to the part where you reach END=n'

Example data below

Does this make sense? If so can any one help me?

Starting data

LMN=ABC:1+BBBB:COULD SAY AN+ZSED:COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+123456+AAAAAAA+ANYVALUES+A'
LINE OF CODE1
LINE OF CODE2
LINE OF CODE3
LINE OF CODE4
LINE OF CODE5
END=5'
LMN=ABC:1+C00016:DIFFERENT VALUES INC SPACES+Z00123:D COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+000001+AAAAAAA+ANYVALUES+A'
LINE OF CODE1
LINE OF CODE2
LINE OF CODE3
END=3'
LMN=FED:1+EDRE:COULD SAY ANYTHING INCLUDING SPACES+FERD:COULD SAY ANSPACES+DDMMYYYY:HHMMSS+9999+AAAAAAA+ANYVALUES+A'
LINE OF CODE1
END=1'
LMN=XYZ:5+BZER:ANYTHING+B456:OTHE TEXT+DDMMYYYY:HHMMSS+801207+JHYTHGH+JUHY01+T'
LINE OF CODE1
LINE OF CODE2
LINE OF CODE3
LINE OF CODE4
LINE OF CODE5
LINE OF CODE6
LINE OF CODE7
LINE OF CODE8
END=8'



I want this to use textpad to amend this to look like this;

LMN=ABC:1+BBBB:COULD SAY AN+ZSED:COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+123456+AAAAAAA+ANYVALUES+A'
123456 LINE OF CODE1
123456 LINE OF CODE2
123456 LINE OF CODE3
123456 LINE OF CODE4
123456 LINE OF CODE5
END=5'
LMN=ABC:1+C00016:DIFFERENT VALUES INC SPACES+Z00123:D COULD SAY ANYTHING INCLUDING SPACES+DDMMYYYY:HHMMSS+000001+AAAAAAA+ANYVALUES+A'
000001 LINE OF CODE1
000001 LINE OF CODE2
000001 LINE OF CODE3
END=3'
LMN=FED:1+EDRE:COULD SAY ANYTHING INCLUDING SPACES+FERD:COULD SAY ANSPACES+DDMMYYYY:HHMMSS+999999+AAAAAAA+ANYVALUES+A'
999999 LINE OF CODE1
END=1'
LMN=XYZ:5+BZER:ANYTHING+B456:OTHE TEXT+DDMMYYYY:HHMMSS+801207+JHYTHGH+JUHY01+T'
801207 LINE OF CODE1
801207 LINE OF CODE2
801207 LINE OF CODE3
801207 LINE OF CODE4
801207 LINE OF CODE5
801207 LINE OF CODE6
801207 LINE OF CODE7
801207 LINE OF CODE8
END=8'

Posted: Wed Feb 23, 2011 10:25 pm
by ben_josephs
There is no easy way that I am aware of to do that in TextPad. It would be very easy using a script in a suitable language, but TextPad does not support scripts.

Posted: Wed Feb 23, 2011 10:50 pm
by kr1
Thanks for your response. As I'm not a developer I wouldn't know where to begin.

Would this be possible through a script in dos? Just trying to know where to start my research.

Any ideas of where to begin would be most appreciated.