Я предполагаю, что мы хотели бы захватить и изменить цвет в форматах CSS, что мы можем сделать, используя выражение, похожее на:
(background(-color)?):\s+(.+?)(\s+)?;
или:
(background-color):\s+(.+?)(\s+)?;
Тест
const regex = /(background(-color)?):\s+(.+?)(\s+)?;/gmi;
const str = `background-color: blue;
background: green;
background: green ;
background: green ;`;
const subst = `$1:yellow;`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log(result);
Схема RegEx
jex.im визуализирует регулярные выражения:
![enter image description here](https://i.stack.imgur.com/ZYP89.png)