如何使用正则表达式实现 Markddown 的 emphasis
或 bold
?
或者如何用 ** **
中的内容替换 re \*\*(.*)\*\*
?
最佳答案
你可以使用re.sub()
:
import re
myRegex = re.compile(r"\*\*(.+?)\*\*")
string = "some **text** and some **more**"
output = myRegex.sub(r"\1", string)
关于python - Markdown强调-重新代入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5797516/