Anda dapat menggunakan regexp_split_to_table
dengan pandangan negatif ke depan untuk kerusakan;
SELECT "ID", regexp_split_to_table("Cars", '((, (?!damaged))| and )') "Cars"
FROM mytable;
ID | Cars
----+-----------------
1 | opel
1 | honda
1 | land rover
2 | ford
2 | porshe, damaged
3 | volkswagen
4 | opel
4 | seat, damaged
(8 rows)
EDIT:Untuk contoh baru Anda, regex harus sedikit diubah;
SELECT "ID", regexp_split_to_table("Cars", '(([,;] (?!damaged))|[,;]? and )') "Cars"
FROM mytable;