Generalize regexpColor function