I have SQL Where clause to run on DataView, but C# DataView does not accept BETWEEN operator. I need to convert any BETWEEN operator in query string to And, example:
Before: Year BETWEEN 2010 and 2014
After: Year >= 2010 and Year <= 2014
I tried this pattern
$.+ BETWEEN .+ AND .+/
This works, but I think you would do better to write a query that matches the required syntax...
var sql = "blah Year BETWEEN 2010 and 2014 blah"; var munged = Regex.Replace(sql, @"\s([A-Za-z0-9_.]+)\s+BETWEEN\s+([0-9]+)\s+and\s+([0-9]+)\s", " $1 >= $2 and $1 <= $3 ", RegexOptions.IgnoreCase);
Note that I'm limiting the handling here to integers; expanding it to cope with strings is much more complex.