uses regex to replace a string between two entity patterns
#replaces a single entity between two patterns
def replacebetween(patt, string, repl):
import re
target = re.match(patt, string)
g = list(target.groups())
g[1] = repl
return ''.join(g)