<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_hpxregion(region):
 """Parse the HPX_REG header keyword into a list of tokens."""


    m = re.match(r'([A-Za-z\_]*?)\((.*?)\)', region)
    if m is None:
        raise Exception('Failed to parse hpx region string.')

    if not m.group(1):
        return re.split(',', m.group(2))
    else:
        return [m.group(1)] + re.split(',', m.group(2))