'A simple CSS selector is a type (e.g., "p") or universal ("*") selector
followed by id selectors, attribute selectors, or pseudo-elements.'

def __init__(self, s):

    self.string = s
    s = s.strip()
    s = s.lower()
    s = ((s.startswith(('#', '.', ':')) and ('*' + s)) or s)
    s = (s.replace('#', '    #') + '    #')
    s = s.replace('.', '    .')
    s = s.replace(':', '    :')
    s = s.replace('[', '    [')
    s = re.sub('\\[.*?\\]', (lambda m: re.sub('    (\\#|\\.|\\:)', '\\1', m.group(0))), s)
    s = re.sub('\\[.*?\\]', (lambda m: _encode_space(m.group(0))), s)
    s = re.sub(':contains\\(.*?\\)', (lambda m: _encode_space(m.group(0))), s)
    s = s.split('    ')
    (self.tag, self.id, self.classes, self.pseudo, self.attributes) = (s[0], [x[1:] for x in s if (x[0] == '#')][0], set([x[1:] for x in s if (x[0] == '.')]), set([x[1:] for x in s if (x[0] == ':')]), dict((self._parse_attribute(x) for x in s if (x[0] == '['))))
