如果我有这个段落的例子:
paragraph = "Peter Piper picked a peck of pickled peppers;" +
"A peck of pickled peppers Peter Piper picked;" +
"If Peter Piper picked a peck of pickled peppers, +
"Where's the peck of pickled peppers Peter Piper picked?"
我有这个正则表达式字符串:
strRegex = "[[:<:]]pick.*[[:>:]]" # match pick/picked/pickled
如何以适合正则表达式的所有单词 BOLD 的方式制作?
请用django查看表格给我建议。谢谢!
答案 0 :(得分:0)
替换itp>
import re
re.sub(r"(.*)it(.*)", r"\1<b>it</b>\2", "Bold it!")
'Bold <b>it</b>!'