0

I would like use regular expression to replace a pattern by an other :

re.compile(r"<class '(.*)'>").sub("\\1", "<class 'int'>")
>>> 'int'

But how can i manage repetition cases ? Like:

re.compile(r"<class '(.*)'>").sub("\\1", "<class 'int'>, <class 'str'>")
>>> 'int\'>, <class \'str'  # i would like 'int, str'
bux
  • 7,087
  • 11
  • 45
  • 86

0 Answers0