【发布时间】:2019-10-19 18:56:47
【问题描述】:
我有以下字符串:message = 'hi <@ABC> and <@DEF>',
以及以下正则表达式:exp = '<@(.*?)>',因此re.findall(exp, message) 输出['ABC', 'DEF']。如何用这些输出替换原始消息匹配,以便得到'hi ABC and DEF'?
【问题讨论】:
-
替换为
r'\1'