It is rather simple with awk (requires an Awk version with gensub(), such as GNU Awk):
$ awk '/oo\+[[:digit:]]{8,}pkp/{$0=gensub(/oo\+/,"o+",2)}1' input.txt
1oo+457864227yexaloo+6784536pkp8907654
2oo+499004227yexalo+69008908pkp8907654
3oo+648968976yexalo+53589094pkp8907654
4oo+490764578yexaloo+6784536pkp8907654
- This will test if the line contains the pattern "oo+, followed by eight or more digits, followed bypkp".
- If so, the gensub()function is used to replace the second match ofoo+byo+on the current line ($0).
- The seemingly stray 1will the print the current line including any modifications.
If you actually want to additionally change the o+ to o:, you need to modify the program as follows:
$ awk '{gsub(/oo\+/,"oo:")} /oo:[[:digit:]]{8,}pkp/{$0=gensub(/oo:/,"o:",2)}1' input.txt
1oo:457864227yexaloo:6784536pkp8907654
2oo:499004227yexalo:69008908pkp8907654
3oo:648968976yexalo:53589094pkp8907654
4oo:490764578yexaloo:6784536pkp8907654
This will first replace all occurences of oo+ with oo: and then apply the same logic as above for oo:,8 or more digits,pkp.
Note that all of the above relies on the structure you presented, i.e. only the second oo+ is followed by digits and then pkp. If the first oo+ can also be followed by only digits and then pkp, or the second happens to not be, but a possibly further occurence of oo+ is, it will break down.
     
    
+with a:, is that intentional? In addition, can we assume there are always two occurences ofoo+and one ofpkp?+after bothoointo a:, is this part of the requirements?sed -E 's/o(o\+[0-9]{8,}pkp)/\1/'(assuming+doesn't need to be changed to:) sincepkpdoesn't pair for the firstoo+oo+, or the second occurrence ofoo+followed by 8-or-more digits? And an we assume each line starts with one-or-more digits followed by "oo+" (which in Perl6-speak is `^^ \d+ oo\+ )? Thx.