JSFiddle - React, Tailwind, and code Playground
JavaScript
str = "Apple Book \"Grand Piano\" Piano";
res = str.replace(/Piano(?!(?:[^"]*"[^"]*")*[^"]*"[^"]*$)/g, "");
alert(res);
str = "Apple Book \"Grand Piano\" Piano";
res = str.replace(/Piano(?!(?:[^"]*"[^"]*")*[^"]*"[^"]*$)/g, "");
alert(res);