fork download
  1. import re
  2. text = r'''Some text *here*:
  3. * first item
  4. * second item
  5. * third item *some bold text*
  6. and the end of text.'''
  7. print(re.sub(
  8. r'^[^\S\n]*\* |\*([^*\r\n]*)\*',
  9. lambda x: f'**{x.group(1)}**' if x.group(1) else x.group(),
  10. text,
  11. flags=re.M)
  12. )
  13.  
Success #stdin #stdout 0.02s 9536KB
stdin
Standard input is empty
stdout
Some text **here**:
* first item
* second item
* third item **some bold text**
and the end of text.