Regex Question in IntelligentOCR Regex Expression Capture Groups

I’m trying to implement an extraction of the last name of a client with the Regex Expressions Extractor on a scanned document.

Sometime the words Agent and Insurance Agent do not appear so I have tried to set it up to look for either or. I did this by making Agent a capture group and then adding a true/false condition to the Insurance Agency.

The problem here is that the UiPath Extractor extracts everything and appears as AgentLastname. When I only want it to extract Lastname, Since I had to make Agent a capture group It extracts that as well. How should I approach this problem?

(?'Agent’Agent)\s+?\n+?(?:\w+)\s+(?:\w+.?\s{1,3})?([a-zA-Z0_]+)\s+?(?(Agent)\s?|Insurance Agency.)

Here is an example text.
"Policy Holder


First Middle Last Insurance Agency."

I’ve made a Regex expression that uses conditional lookbehinds. This is what I came up with. I made it using I get an error “Data Extraction Scope: Sequence contains no elements”. It only causes exceptions if it is capturing the True condition for the Regex.

(?(?<=Agent)(?:\s+?\n+?(?:\w+)\s+(?:\w+.?\s{1,3})?([a-zA-Z0]+)(?:\s+?[a-zA-Z0-9]+)?\s+?)|(?:(?:Policy\sHolder)\s+?\n+?(?:[a-zA-Z]+\s+?)([a-zA-Z]+)\s+?(?:[a-zA-Z0-9]*?\s+?)(?:Inurance Agency.)))

I see a think in options called explicit capture. That seems to capture only what I want and avoiding the type of conditionals I am using. How do you use explicit capture? Any ideas?