import re
regex = re.compile(r"\[Remote IP\]:\s\[(?<remoteIp>([0-9\.]{0,}))\]", flags=re.MULTILINE)
test_str = ("****************************************************************\n"
"[2020-12-31 10:07:04,967] [INFO ][c.s.d.s.activityLauncher.access] *********************[ ACCESS-END Info ]*********************\n"
"- [Date]: [2020-12-31 10:07:04.967]\n"
"- [Remote IP]: [10.30.20.20]\n"
"- [Correlation ID]: [03d93d63-9e42-4dac-9e0b-1252d149e297]\n"
"- [Trace ID]: [e7ca75e6b6d2dac0]\n"
"- [Span ID]: [34de12785de46a27]\n"
"- [Method]: [dmIndivCheck]\n"
"- [RESPONSE TIME]: [49ms]\n"
"- [Args]: [[IndivRequestParamDTO(DCOL_DATA_ID=EDP20201231100704849-MXNI_DCP_1, ACTIVITY_ID=EDP_DCOL_RESPONSE_DECISION, MODEL_UUID=fbb02026-6ace-4901-be2e-93c2d7341af6)]]\n")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
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