I am totally new to reg-ex and I want to get validation for the string
for valid combination of logical operators like ( ! , & , ( , ) , | ) . for Example if & | combined than it should be invalid as AND OR
should come together. likewise possible invalid combination are &|, |& , (), !& ,&! etc
like example of below String
1. (ABC)&(DFG)|!(ZXC) - pass because all operators are correctly combined
2. !(ABC|DKJ)&VBN - pass
3. !(ADF&(!&(BER|CTY))|DGH) = failed as !& combined
4. !(ABC&DKJ)&|VBN - failed as & | combined
I know their several ways like I can use String's
contains
method to get check and reject if not passed the validation. But I am looking for solution through reg-ex
in java