If it takes the first alternative, $2 is an empty match. You might want to split this into two separate matches with \G anchors. Or make the first + a * and remove the bar. Depends on what you need to happen.
Caution: Contents may have been coded under pressure.