I have a string like this
'(1 and 2 and 3) or 4 and 5'
It should be constructed from
array =[1 ,2 ,3,4,5 '(', ')', '', 'and', 'or', 'AND', 'OR', ' '];
it can use any combination but should be from this array only.
I have tried
const arr1 = value.trim().split('');
for (let i = 0; i < arr1.length; i += 1) {
if (!arryOfContaining.includes(arr1[i])) {
return true;
}
}
return false;
But the problem is how to split the string. it will have always space in between words but not with brackets. Any help?