JSFiddle - React, Tailwind, and code Playground

JavaScript

try {
    var color = 'rgb(  123,   12 ,    12   )';
    var matchColors = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/;
    var match = matchColors.exec(color);
    if (match !== null) {
        document.write('Red: ' + match[1] + ' Green: ' + match[2] + ' Blue: ' + match[3]);
    }

}
catch (e) {
    alert(e.message);
}