Q:

String slicing in numpy array

Say we have an numpy.ndarray with numpy.str_ elements. For example, below arr is the numpy.ndarray with two numpy.str_ elements like this:
arr = ['12345"""ABCDEFG'  '1A2B3C"""']

Trying to perform string slicing on each numpy element.
For example, how can we slice the first element '12345"""ABCDEFG' so that we replace its 10 last characters with the string REPL, i.e. 
arr = ['12345REPL'  '1A2B3C"""']

Also, is it possible to perform string substitutions, e.g. substitute all characters after a specific symbol?

A:

Strings are immutable, so you should either create slices and manually recombine or use regular expressions. For example, to replace the last 10 characters of the first element in your array, arr, you could do:
import numpy as np
import re

arr = np.array(['12345"""ABCDEFG', '1A2B3C"""'])
arr[0] = re.sub(arr[0][-10:], 'REPL', arr[0])

print(arr)
#['12345REPL' '1A2B3C"""']

If you want to replace all characters after a specific character you could use a regular expression or find the index of that character in the string and use that as the slicing index.
EDIT: Your comment is more about regular expressions than simply Python slicing, but this is how you could replace everything after the triple quote:
re.sub('["]{3}(.+)', 'REPL', arr[0])

This line essentially says, "Find the triple quote and everything after it, but only replace every character after the triple quotes."

