Core: Optimize for selector strings starting with an #id

By expanding the regular expression for matching simple #id:s to
conditionally include an expression following the #id and piggy-
backing on the existing code path, we can optimize performance
for selectors of the following pattern: $("#id expr")