Replace or delete parts of text (iOS)

how replace or delete text from point to point?

If the points are the same, you can create a list and the replace the respective item in the list.

hi, dear
I would like to delete in an alphanumeric string starting from a point p1 to a point p2

Is the string the same size.

Or it is various sizes but you know you only want to keep the first x characters and the last Y characters.

You can use this

ok Cian,
but it’s not exactly the same thing because in the text there can be more occurrences of the same substring.

Give me an example of the string please

ok Cian,
trying to give you an example I understood your solution. it can work in my case.
Many thanks.