import re line = "" pattern = r"<[^|]*\|WPos:([^,]*),([^,]*),([^|]*)\|" m = re.match(pattern, line) if m: print("Group 1 (X):", m.group(1)) print("Group 2 (Y):", m.group(2)) print("Group 3 (Z):", m.group(3)) else: print("No match found.")