import re
regex = re.compile(r"(\w+\s+\d+,\d+\s+\d+,\d+\s+)\((\s+\d+\s+)\)(\s+)\((\s+\d+,\d+\s)\)(\s+\d+)", flags=re.MULTILINE)
test_str = "IBNR 13,123 1,234 ( 556 ) ( 2,355 ) 934 "
subst = "$1$2$3$4$5"
result = regex.sub(subst, test_str)
if result:
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html