const rgbString: string = "rgb(0, 164, 255)";
let matchResult: any = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
console.log(matchResult + "\n");
delete(matchResult[0]);
for (let i: number = 1; i <= 3; i++) {
matchResult[i] = parseInt(matchResult[i]).toString(16);
if (matchResult[i].length == 1) {
matchResult[i] = '0' + matchResult[i];
}
}
const hexString: string ='#' + matchResult.join('').toUpperCase();
console.log(hexString);
/*
run:
rgb(0, 164, 255),0,164,255
#00A4FF
*/