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-
In reply to Re: Parsing a boolean search string for SQL query
by gjb
in thread Parsing a boolean search string for SQL query
by bradcathey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |