Use \A and \z in regular expressions to avoid newline issues. Also, do not consider any address that begins with 127 to be a loopback IP.
Merge pull request #390 from boone/improve_query_regex

Improve regular expressions for queries.