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
  • 221,139
  • 17
  • 121
  • 189
liorblob
  • 497
  • 1
  • 5
  • 17

1 Answers1

0
import re

line = re.sub(
           r"<@(.*?)>", 
           r"\1", 
           line
       )
ibarrond
  • 5,342
  • 2
  • 20
  • 38