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
  • 6,261
  • 9
  • 39
  • 77

0 Answers0