Replacing string involving two lines ?
Hi all, I’m hoping somebody can help me here…
Objects that are orbiting earth (satellites and debris etc) can be readily tracked using ‘tracking software’, this software requires a downloadable and regularly updated text file filled with ‘three line element sets’ (TLE’s)… thousands of them. Each three line set relates to a specific object in space, the first line always contains only the object name. The second line always begins with ‘1’ and the objects catalog number followed closely with a ‘U’, the third line always begins with a ‘2’ and the objects catalog number.
Here’s a TLE for a weather satellite called ‘NOAA 19’ whose catalog number is ‘33591’.
1 33591U 09005A 18332.92647966 +.00000023 +00000-0 +37991-4 0 9999
2 33591 099.1614 314.3771 0013267 221.9200 138.0956 14.12320225505165
Here is an example of 4 different ‘TLEs’, each having the same name (SL-16 DEB) but each has a different catalog number (22381U, 22382U, 22387U, 22388U).
1 22381U 92093BW 18332.79325499 +.00002160 +00000-0 +35547-3 0 9990
2 22381 070.5420 312.0199 0024743 158.5571 201.6621 14.71692499349425
1 22382U 92093BX 18332.73589465 +.00000212 +00000-0 +19422-3 0 9990
2 22382 070.8656 318.1144 0170278 262.9073 151.1030 13.87756155306599
1 22387U 92093CC 18332.57725812 -.00000136 00000-0 -54247-4 0 9997
2 22387 70.8928 251.7496 0116487 269.9004 155.9187 14.02338453320249
1 22388U 92093CD 18332.76789544 +.00000548 +00000-0 +32478-3 0 9997
2 22388 070.9537 206.7684 0106037 084.6674 024.9629 14.09137400323190
Finding and Replacing the term ‘SL-16 DEB’ is of course very easily done but will replace ALL occurrences of the term. But what I’d like to know is…
Looking at the example above, how can I replace only the occurrence of ’SL-16 DEB’ that is followed by ’1 22387U’ on the next line ?
Hoping someone can help. Many thanks.
How about using a regular-expression replacement and use
^SL-16 DEB\R1 22387Uas the Find what expression? Of course you don’t say what you want to replace it with, so I can’t comment on that…
\Rmeans “line-ending character(s)”
Oh wait, maybe you do describe it. Maybe change the Find what to
^SL-16 DEB(?=\R1 22387U)and then replace with whatever you want. The
)part will just make sure that your second-line text matches, but it won’t be replaced with your replace expression; only the first line contents will.
Many thanks for your reply. I’m trying things now…
Maybe I wasn’t clear on what I want to replace it with.
In the third example (SL-16 DEB… 22387U), say I wanted to replace the ’SL-16 DEB’ to ’SX-17 DEB'…
(i.e. ONLY that entry that is followed on the next line by ‘1 22387U’
Yes, so the SECOND answer I provided should do nicely. :-)
Hello, @terry-grafff,@scott-sumner and All,
I do think that Scott's solution is exactly what you were looking for. So, I won’t say anything more about it !
But I just wanted to thank you, Terry, for showing us what a catalogue of celestial objects looks like ! Personally, I have always been interested in astronomy, although I have no real practice with adequate equipment !
I’m, simply, a fan of the TV channel "Discovery Science" shows ( “Journey through Space-Time”, “NASA Files”, “Keys to the Universe”, etc… ) and I am always fascinated by most of the topics covered !
That works great, many, many thanks… it will save me a lot of …copy/paste/copy/paste/copy/paste/… much appreciated. Notepad++ is a really great program.
No problem on the minor tutorial about satellite elements. I’m afraid I’m not too big on astronomy itself, my interest lies in the tracking of amateur radio satellites and receiving and decoding their radio signals back to earth. My antennas are on a rotor that tracks them across the sky and so a sat tracking program with up to date elements (TLE’s) is essential.
As for the various Discovery Channels… I did love them… but I don’t bother with them anymore as I have found they are sadly, destroyed with advert breaks. To me they have become unwatchable… 10 min clip, 2 mins of what’s after the TV break, TV ads (cruelty), 2 mins… of what happened before the break, 2 mins of what’sto come next… 5 mins clip… TV ads… etc. ad nauseum :/.
Take care and thanks.
Hello, @terry-grafff, and All,
Oh, unfortunately, how right you are ! All these advert breaks, pre and post-shows are really a calamity :-((( On French TV, as everywhere else I suppose, they tend to increase, year after year !
We still have, on Net, the possibility to just get, on very few sites, the Knowledge, but for how long ?