I'm trying to take only expressions like 'A==1' or 'D1 >= 2' from a string (including spaces).
For example:
From - '(A == 3 AND B == 4) OR ( A==1 AND B==2)'
I expect to get: [A == 3, B == 4, A==1, B==2].
Here's my code:
let myString = '(A == 3 AND B == 4) OR ( A==1 AND B==2)';
const result = myString.match(/[a-z0-9\s]+(>|<|==|>=|<=|!=|\s)\d/gi);
console.log(result); //result => [A == 3 ,AND B == 4,A==1 ,AND B==2]
I want my regex to take only the specific pattern of {param}{operator}{param} but with blank spaces.
I tried many ways, but none was successful.
I would appreciate any help.