My string is as follows:
var query = "@id >= 4 OR @id2 < 6 AND @id3 >= 5 AND @name = foo "
I want to reverse every "equality" test in this string. This means replacing ' >=' with ' <', ' <' with ' >=', and ' =' with ' !='.
The desired result is:
var reverseQuery = "@id < 4 OR @id2 >= 6 AND @id3 < 5 AND @name != foo "
We cannot simply use:
reverseQuery = query.replace(/>=/g, "<").replace(/</g, ">=").etc
Because the outcome of this would be
@id >= 4 OR @id2 >= 6 AND @id3 >= 5 AND @name != foo
So, what would be an elegant solution for achieving this?
Thank you,