Find the position of a set of text, cut out that as a substring, and then replace that One instance in the original string

Hey guys I need to be able to:

  • find all regex matches from a large string of text

  • output the position of that text to a variable (one at a time)

  • extract four characters starting with the position number and put into a variable

  • remove one character from this new for character variable

  • replace the first instance of that original text four character with the new three character text

  • Regex I’m using to get the matches: [A-Za-z0-9][>]{2}[A-Z$]

  • Examples of the matched text that will come out of the larger string:
    m>> 8>>
    3>>$

  • What I need those strings to be replaced with (essentially just removing one ‘>’ sign, and I can’t just do this to the original string as a whole because I need to keep text sections with three ‘>’ signs as they are)
    m> 8>
    3>$

  • Then replace those original 4 character matches with the 3 character matches

Hi @css

Can you share some examples and outputs to understand

Thanks