RegEx is NOT well-suited for this task.
I would use either ASobjC or JXA -- both have a SET object that automatically removes dups.
JXA:
let uniqueName = [...new Set(allNames)];
Use the KM JavaScript for Automation to run the script.
This also shows you how to get a KM variable from JXA, and how to output back to KM.