I have values like this in one of the column PIDS of my SQL Server table. I would like to split this column into two separate columns based on the ID value please. Any value after GID: should go to GID column, and any value after PACKAGEID: should go to PACKAGEID column. Could you please help me with this?
| PIDs |
|---|
| GID: 2672, PACKAGEID: 91290 |
| PACKAGEID: 130116, GID: 7d78b |
| GID: 09e541, PACKAGEID: 17105 |
| GID: 14e3ba, PACKAGEID: 80017 |
| PACKAGEID: 730829, GID: a871c |
| PACKAGEID: 1009409, GID: c8b2 |
Expected output - either like this:
| GID | PACKAGEID |
|---|---|
| 2672 | 91290 |
| 7d78b | 130116 |
| 09e541 | 17105 |
| 14e3ba | 80017 |
| a871c | 730829 |
| c8b2 | 1009409 |
or this:
| GID | PACKAGEID |
|---|---|
| GID:2672 | PACKAGEID:91290 |
| GID:7d78b | PACKAGEID:130116 |
| GID:09e541 | PACKAGEID:17105 |
| GID:14e3ba | PACKAGEID:80017 |
| GID:a871c | PACKAGEID:730829 |
| GID:c8b2 | PACKAGEID:1009409 |
^(?=.*\bGID: *(?<GID>[\da-z]+\b))(?=.*\bPACKAGEID: *(?<PACKAGEID>\d+\b))that uses named capture groups. Demo. See the answers here for examples on how to extract values of named capture groups.string_split