On Thu, May 8, 2008 at 12:12 PM, DanTMan dan_the_man@telus.net wrote:
"/^\s*(\S+|`[^`]+`)(.\S+|.`[^`]+`)?\s*$/i" All we need to test for is non-whitespace. Anything which is completely unbroken by whitespace can't be a query at all. "SELECT*FROMfoo" ;)
But "database . table" is valid, since you make the point about whitespace. So
/^\s*(\S+|`[^`]+`)(\s*.\s*(\S+|`[^`]+`))?\s*$/
should work.
And I handily moved the condition to the second group to optimize the regex. The \S+ alone will completely match 'foo.bar' without any backtracking or anything from the processor.
I don't think we need to worry much about optimizing this regex. :)