def replacement(self, m):

        found = True
        if m.group('webcolors') and 'webcolors' in self.allowed_colors:
            self.region = sublime.Region(m.start('webcolors') + self.start, m.end('webcolors') + self.start)
        elif m.group('hexa') and 'hexa' in self.allowed_colors:
            self.region = sublime.Region(m.start('hexa') + self.start, m.end('hexa') + self.start)
        elif m.group('hex') and 'hex' in self.allowed_colors:
            self.region = sublime.Region(m.start('hex') + self.start, m.end('hex') + self.start)
        elif m.group('hexa_compressed') and 'hexa_compressed' in self.allowed_colors:
            self.region = sublime.Region(m.start('hexa_compressed') + self.start, m.end('hexa_compressed') + self.start)
        elif m.group('hex_compressed') and 'hex_compressed' in self.allowed_colors:
            self.region = sublime.Region(m.start('hex_compressed') + self.start, m.end('hex_compressed') + self.start)
        elif m.group('rgb') and 'rgb' in self.allowed_colors:
            self.region = sublime.Region(m.start('rgb') + self.start, m.end('rgb') + self.start)
        elif m.group('rgba') and 'rgba' in self.allowed_colors:
            self.region = sublime.Region(m.start('rgba') + self.start, m.end('rgba') + self.start)
        elif m.group('gray') and 'gray' in self.allowed_colors:
            self.region = sublime.Region(m.start('gray') + self.start, m.end('gray') + self.start)
        elif m.group('graya') and 'graya' in self.allowed_colors:
            self.region = sublime.Region(m.start('graya') + self.start, m.end('graya') + self.start)
        elif m.group('hsl') and 'hsl' in self.allowed_colors:
            self.region = sublime.Region(m.start('hsl') + self.start, m.end('hsl') + self.start)
        elif m.group('hsla') and 'hsla' in self.allowed_colors:
            self.region = sublime.Region(m.start('hsla') + self.start, m.end('hsla') + self.start)
        elif m.group('hwb') and 'hwb' in self.allowed_colors:
            self.region = sublime.Region(m.start('hwb') + self.start, m.end('hwb') + self.start)
        elif m.group('hwba') and 'hwba' in self.allowed_colors:
            self.region = sublime.Region(m.start('hwba') + self.start, m.end('hwba') + self.start)
        else:
            found = False
        return found
See if match is a replacement of an existing color.
dataset/ETHPy150Open facelessuser/ColorHelper/color_helper_insert.py/PickerInsertCalc.replacement