Improved check for empty query so it uses one regex instead of two. Included trim of spaces directly in the regex and changed string comparison to length comparison
Merge pull request #1 from davideserafini/regex-optimization

Improved check for empty query