This regex: \b([A-z*]+)-(?=[A-z*]+\b)
with this replacement: $1
Applied on:
Jean-Pierre bought "blue-green-red" product-2345 and other blue-red stuff.
Gives me:
Jean Pierre bought "blue green red" product-2345 and other blue red stuff.
While I want:
Jean Pierre bought "blue-green-red" product-2345 and other blue red stuff.
https://regex101.com/r/SJzAaP/1
EDIT:
I am using Clojure (Java)
EDIT 2:
yellow-black-white
-> yellow black white
product_a-b
-> product_a-b
EDIT 3: Accepted answer translated in Clojure
(clojure.string/replace
"Jean-Pierre bought \"blue-green-red\" product-2345 and other blue-red-green stuff yellow-black-white product_a-b"
#"(\"[^\"]*\")|\b([a-zA-Z]+)-(?=[a-zA-Z]+\b)"
(fn [[s1 s2 s3]] (if s2 s1 (str s3 " "))))
;;=> "Jean Pierre bought \"blue-green-red\" product-2345 and other blue red green stuff yellow black white product_a-b"