I don't get it. Where did the characters marked in red above come from?
I can understand wanting to remove the final two components of the selected pathnames, but I don't understand the logic that seems to produce random characters that do not appear in the input. Also, you said you wanted to remove a few words. Pathname components are not usually described as "words". And, is a few always two, or is there something else you haven't told us?