Regex that matches all spaces but:
\sand\s\sor\s\sbut\s,\s
Input
font weight, width and height, background, or background color, but transform style
input.replace(regex,"-")
Matches
fontweight, width and height, background, or backgroundcolor, but transformstyle
Replace
font-weight, width and height, background, or background-color, but transform-style
Output
font-weight, width and height, background, or background-color, but transform-style