Improve regular expressions for queries.

Many of the query regular expressions use ^ and $, which permit newlines in Ruby. We can use \A and \z instead. In addition, any address that began with "127" would return true on loopback_ip_address? These issues have been corrected in query.rb with tests.

Note: there are also several other instances of ^ and $ in regexes in the code. As these are mostly related to various provider implementations, I haven't reviewed if using \A and \z would be more appropriate for them.

Thanks!