fork(1) download
  1. import re
  2. text = "Hi. My name is _John_. I am _20_ years old."
  3. pattern = "_([^_]*)_"
  4. print re.sub(pattern, r'<b>\1</b>', text)
  5.  
Success #stdin #stdout 0.03s 6680KB
stdin
Standard input is empty
stdout
Hi. My name is <b>John</b>. I am <b>20</b> years old.