import re

regex = r"(?<=[a-zA-Z])(\d)(?!\d)"
test_str = ("Z9_M50_P3_2X_MY_STRING")
subst = "0\\1"
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)

if result:
    print (result)

