import re
a = '*my italic text*'
b = '**NOT italic**'
x = re.sub(r'[*](?!\*)([^\*]+)[*](?!\*)', r'<em>\1</em>', a)
y = re.sub(r'[*](?!\*)([^\*]+)[*](?!\*)', r'<em>\1</em>', b)
print(x, y)
aW1wb3J0IHJlCmEgPSAnKm15IGl0YWxpYyB0ZXh0KicKYiA9ICcqKk5PVCBpdGFsaWMqKicKeCA9IHJlLnN1YihyJ1sqXSg/IVwqKShbXlwqXSspWypdKD8hXCopJywgcic8ZW0+XDE8L2VtPicsIGEpCnkgPSByZS5zdWIocidbKl0oPyFcKikoW15cKl0rKVsqXSg/IVwqKScsIHInPGVtPlwxPC9lbT4nLCBiKQpwcmludCh4LCB5KQ==