我一直在编写这段代码,这似乎是一辈子的事情,但似乎无法让它发挥作用。
pattern = "\[([a-zA-Z0-9].*?)#([a-zA-Z0-9].*?)\]"
pattern_obj = re.compile(pattern, re.MULTILINE)
translation = pattern_obj.sub("<ol>\\1</ol>", translation)
我在这里要做的是更改一些文本,即:
[
# This is item number one in an ordered list. #
# And this is item number two in the same list. #
]
进入:
<ol>
#This is item number one in an ordered list. #
#And this is item number two in the same list. #
</ol>
本质上,它应该在文本中的某处用 # 标识 [ 和 ] 之间的任何文本,并将 [<ol>
和 ] 更改为</ol>
同时保持所有内部文本相同。有人可以请教吗?
先感谢您!