0

我一直在编写这段代码,这似乎是一辈子的事情,但似乎无法让它发挥作用。

translation = re.sub("'''[a-zA-Z0-9].*?'''", "<b>[what do I put here to copy [a-zA-Z0-9].*?</b>", translation)

Here I'm trying to replace " ''' [text] ''' " with " <b> [text] </b>. What would I have to put between <b> and </b> to make it copy across the text?

先感谢您!

4

2 回答 2

2

使用捕获组并通过以下方式引用它\1

translation = re.sub(r"'''([a-zA-Z0-9].*?)'''", r"<b>\1</b>", translation)
于 2013-05-28T09:22:34.700 回答
0
translation = re.sub("'''([a-zA-Z0-9]*)'''", r"<b>\1</b>", translation)

类似的东西?

于 2013-05-28T09:24:43.383 回答