fork download
  1. import re
  2. pattern = r"\*{2}|\*([^*]*)\*"
  3. text = "Hello *there* are two aster**es next to each other"
  4. print( re.sub(pattern, lambda x: f'<em>{x.group(1)}</em>' if x.group(1) else x.group(), text) )
Success #stdin #stdout 0.02s 9472KB
stdin
Standard input is empty
stdout
Hello <em>there</em> are two aster**es next to each other