def convertPinyin(s):
    return re.sub('([aeiou\xfcv\xdc]{1,3})(n?g?r?)([012345])',
        convertPinyinCallback, s, flags=re.IGNORECASE)
print(convertPinyin('Ni3 hao3 ma0?'))
Convert numbered pinyin to pinyin with tone marks