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)
aW1wb3J0IHJlCgpyZWdleCA9IHIiKD88PVthLXpBLVpdKShcZCkoPyFcZCkiCnRlc3Rfc3RyID0gKCJaOV9NNTBfUDNfMlhfTVlfU1RSSU5HIikKc3Vic3QgPSAiMFxcMSIKcmVzdWx0ID0gcmUuc3ViKHJlZ2V4LCBzdWJzdCwgdGVzdF9zdHIsIDAsIHJlLk1VTFRJTElORSkKCmlmIHJlc3VsdDoKICAgIHByaW50IChyZXN1bHQpCgo=