Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的网络应用程序(django)中,我使用这样的东西(在循环中)自动更改带有内部链接的特殊单词:
value = re.sub(r'\b' + keyword.name +r'\b', unicode(internal_link), value, flags=re.UNICODE|re.IGNORECASE)
当它已经是一个链接时,有没有办法不改变一个词?
(例如介于>和</a>字符之间或更好的东西)。
>
</a>
像这样的东西:
reg = r'<//a{0}>|\b{0}\b'.format(keyword.name) value = re.sub(reg, lambda match: match.group(1) if match.group(1) else unicode(internal_link), value, flags=....)