import re
regex = re.compile(r"\"(?:[Aa]uthor[s]?|[Jj]ournalist|[Pp]erson)\":(?:{(?:[^}[]+)?\"name[s]?\":\[?(?:\"name\":)?\"|\")([^\"\\]+)", flags=re.MULTILINE)
test_str = ("\"author\":\"Lucy Bode\",\"publisher\":{\"name\":\"Channel Void\"\n"
"\"author\":{\"name\":\"Lucy Bode\"},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"author\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"author\":{\"names\":[\"name\":\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"author\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"journalist\":\"Lucy Bode\",\"publisher\":{\"name\":\"Channel Void\"\n"
"\"journalist\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"journalist\":{\"names\":[\"name\":\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"journalist\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"authors\":\"Lucy Bode\",\"publisher\":{\"name\":\"Channel Void\"\n"
"\"authors\":{\"name\":\"Lucy Bode\"},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"authors\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"authors\":{\"names\":[\"name\":\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"authors\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"person\":{\"name\":\"Lucy Bode\"},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"person\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"person\":{\"names\":[\"name\":\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"person\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"Person\":{\"name\":\"Lucy Bode\"},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"Person\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"Person\":{\"names\":[\"name\":\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"Person\":{\"names\":[\"Lucy Bode\"]},\"publisher\":{\"name\":\"Channel Void\"\n"
"\"author\":{\"@type\":\"Person\",\"name\":\"Lucy Bode\"}\n"
"\"image\":{\"@type\":\"ImageObject\",\"url\":\"https://static.nationalgeographic.co.uk/files/styles/image_3200/public/rewilding-redonda.jpg?w=1900&h=1267\",\"width\":1900,\"height\":1267,\"author\":{\"@type\":\"Person\",\"name\":\"Ed Marshall, Redonda Restoration Programme\"},")
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