(PDB-950) Added validation for regexps in queries

This commit adds a validation for regexps in queries as was proposed in PDB-950
Hmm interesting.

The general concern I have with this facility, is that it enforces Java regular expressions, which isn't POSIX regexp which is ultimately what we are exposing here: http://www.postgresql.org/docs/9.0/static/functions-matching.html#FUNCTIONS-POSIX-TABLE. Although in practice I'm sure this catches a lot of the problems, what if java regex doesn't support something PG does for example.