Parsing a search string

Brian Beck exogen at gmail.com
Fri Dec 31 15:53:04 EST 2004


Freddie wrote:
> I'm trying to parse a search string so I can use it for SQL WHERE 
> constraints, preferably without horrifying regular expressions. Uhh yeah.

If you're interested, I've written a function that parses query strings 
using a customizable version of Google's search syntax.

Features include:
   - Binary operators like OR
   - Unary operators like '-' for exclusion
   - Customizable modifiers like Google's site:, intitle:, inurl: syntax
   - *No* query is an error (invalid characters are fixed up, etc.)
   - Result is a dictionary in one of two possible forms, both geared 
towards being input to an search method for your database

I'd be glad to post the code, although I'd probably want to have a last 
look at it before I let others see it...

--
Brian Beck
Adventurer of the First Order



More information about the Python-list mailing list