in reply to Parsing a boolean search string for SQL query

It would be much simpler to work the other way round, i.e. by replacing all query terms 'x' by 'fieldname = x'. This would mean something like:

s/(\w+)/$1 ne 'OR' && $1 ne 'AND' && $1 ne 'NOT' ? "fieldname = '$1' +" : $1/eg;

Hope this helps, -gjb-

Replies are listed 'Best First'.
Re: Re: Parsing a boolean search string for SQL query
by bradcathey (Prior) on Sep 01, 2003 at 18:19 UTC
    Brilliant gjb! The incredible power of reg exp's is again demonstrated. I had no idea you could use the implied if/then/else like that. Oh, I love the Monastery.