             return no if not (val = tag.attr(a.name))
             esc = a.escapedValue
             switch a.operator
-                when '^=' then return no unless test(      "^#{esc}"       ,val)
-                when '$=' then return no unless test(       "#{esc}$"      ,val)
-                when '~=' then return no unless test("(^|\\s)#{esc}(\\s|$)",val)
-                when '|=' then return no unless test(      "^#{esc}(-|$)"  ,val)
                 when '*=' then return no if val.indexOf(a.value) is -1
                 when  '=' then return no if val isnt a.value
+                when '^=','$=','~=','|='
+                    return no unless a.operatorRegExp.test(val)
                 else return no
         # pseudos
         # TODO

        @builder = @template.xml ? @template
        @builder._selectors = ({i, level:0} for s,i in @selectors)
        @builder.on('add', @onadd.bind(this))

    onlistener: (event, listener) ->
        for sel in parse event
            sel.event =  event
            @builder?._selectors.push {i:@selectors.length, level:0}
            @selectors.push sel
        this

    onadd: (parent, el) ->

parse = require 'slick/lib/parser'

# TODO selector using asyncxml.Builder::register


class Selector extends EventEmitter
