This regex gets the first, the last and the middle part as capturing groups and matches the trailing semicolon as a non-capturing group. This allows you to resort CSV columns.