JSFiddle - React, Tailwind, and code Playground

JavaScript

var convert = function(rgb)
{    
    var s = rgb.replace(/[^\d\s]/g, '').split(' ');
    
    return {
        r: s[0],
        g: s[1],
        b: s[2]
    };
}

console.log(convert("rgb(255, 255, 255)"));