0

I have the following string: message = 'hi <@ABC> and <@DEF>', And the following Regex: exp = '<@(.*?)>', so that re.findall(exp, message) outputs ['ABC', 'DEF']. How can I replace the original message matches with those outputs so I get 'hi ABC and DEF'?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
liorblob
  • 507
  • 1
  • 6
  • 19

1 Answers1

0
import re

line = re.sub(
           r"<@(.*?)>", 
           r"\1", 
           line
       )
ibarrond
  • 6,617
  • 4
  • 26
  • 45