function rgb2hex(sRGB) {
    let rgb = sRGB.replace(/[\s*|rgb\(|\)]/gi, '').split(',')
    let hexCode = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
    for(let i=0,imax=rgb.length; i<imax;i++) {
      if(isNaN(+rgb[i])){
        return sRGB
      }
      let v = +rgb[i]
      if (v > 255) {
        return sRGB
      }
      rgb[i] = `${hexCode[parseInt(v/16)]}${hexCode[parseInt(v%16)]}`
    }
    return `#${rgb.join('')}`
}