I am trying to extract one or two names from a text string. The string can be a single name or two names with variations listed below. I used regex101.com to generate and test the regx, I am assigning variable names to each portion of the regular expression, so I repeat the Parse text command for each variable to extract. I have six Parse Text commands to grab all the data from the string. Here is the regx and sample data. I get a syntax error when I use the generated regx. I removed the '^' and the '$' but I still get the error. The first and second middle Initial are optional, and there may not be a second name.
Regx:
^(?<LAST_NAME>[\w]+)\s(?<FIRST_NAME>[\w]+)(\s?(?<MID_INITIAL>[\w]+)([%+]((?<LAST_NAME2>[\w]+)\s)?(?<FIRST_NAME2>[\w]+)\s(?<MID_INITIAL2>[\w]+))?)?$
Sample Data:
LAST_NAME FIRST_NAME MID_INITIAL
LAST_NAME FIRST_NAME MID_INITIAL+FIRST_NAME2 MID_INITIAL2
LAST_NAME FIRST_NAME MID_INITIAL%FIRST_NAME2 MID_INITIAL2
LAST_NAME FIRST_NAME MID_INITIAL+LAST_NAME2 FIRST_NAME2 MID_INITIAL2
LAST_NAME FIRST_NAME MID_INITIAL%LAST_NAME2 FIRST_NAME2 MID_INITIAL2
LAST_NAME FIRST_NAME
LAST_NAME FIRST_NAME+FIRST_NAME2 MID_INITIAL2
LAST_NAME FIRST_NAME%FIRST_NAME2 MID_INITIAL2
LAST_NAME FIRST_NAME+LAST_NAME2 FIRST_NAME2 MID_INITIAL2
LAST_NAME FIRST_NAME%LAST_NAME2 FIRST_NAME2 MID_INITIAL2