Improve exact match, give lower priority to pre-releases when matching against *.

Improved your original PR, and also fixed https://github.com/bower/bower/issues/782
Note that `util/semver` has all the `semver` module methods but some of them are custom to fulfil our needs.
We should  replace all `require('semver')` with this new `util/semver` for consistency.