import re
regex = re.compile(r"(?<=\<)(.*?)(?=\>)")
test_str = ("<http://192.168.1.10:8080/longUrl>; rel=\"recording-session\",\n"
"<http://192.168.1.10:8080/realLongUrl>; rel=\"h264-session-sdp\", \n"
"<http://192.168.1.10:8080/realLongDifferentUrl>; rel=\"h264-session-sdp\", \n"
"<rtp://239.1.1.18:5006>; rel=\"destination-high\", \n"
"<rtp://239.1.1.17:5006>; rel=\"destination-low\"")
match = regex.search(test_str)
if match:
print(f"Match 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