import re
def m(r, s):
mtc = re.match(r, s)
if mtc:
return s
return "false"
def italic(s):
if m(r'\*{2}[^\*]+\*{2}', s) == 'false':
return re.sub(r'\*([^*]+)\*', r'<em>\1</em>', s)
return s
print(italic('my plain text'))
print(italic('*my italic text*'))
print(italic('**now it is bold**'))
aW1wb3J0IHJlCmRlZiBtKHIsIHMpOgogICAgbXRjID0gcmUubWF0Y2gociwgcykKICAgIGlmIG10YzoKICAgICAgICByZXR1cm4gcwogICAgcmV0dXJuICJmYWxzZSIKZGVmIGl0YWxpYyhzKToKICAgIGlmICBtKHInXCp7Mn1bXlwqXStcKnsyfScsIHMpID09ICdmYWxzZSc6CiAgICAgICAgcmV0dXJuIHJlLnN1YihyJ1wqKFteKl0rKVwqJywgcic8ZW0+XDE8L2VtPicsIHMpCiAgICByZXR1cm4gcwpwcmludChpdGFsaWMoJ215IHBsYWluIHRleHQnKSkKcHJpbnQoaXRhbGljKCcqbXkgaXRhbGljIHRleHQqJykpCnByaW50KGl0YWxpYygnKipub3cgaXQgaXMgYm9sZCoqJykp