If you put a dollar sign at the end, it will only return the last match (because
$
means "end of the line" in a regular expression).
When I tried this out, it matched
": USA"
rather than
"USA"
and to fix that, you can add
.*:
(note the space after the colon) to the end of the
(?<= )
group, and then you can replace the whole
.[^\d]*\b
part by
\w+
(
\w
is a "word character").
So, all this together gives:
(?<=(?i)((C)0230).*((R)1410).*((S)\.05.02).*(life obligations).*: )\w+$
(Or, an alternative without regex: check that the string contains C0230 and everything else, then split on
": "
and grab the last element of the result array)