0

I want to create a Regex expression to validate logical AND OR string combonation and its corresponding opening and closing () brackets. i am using C#

string validator = @"^(?=^[^()]*(?>[^()]+|\((?<DEPTH>)|\)(?<-DEPTH>))*(?(DEPTH)(?!))[^()]*$)[(]*[0-9a-zA-Z]+[)]*(\s+(AND|OR)\s+[(]*[0-9a-zA-Z]+[)]*)*$";

when i tried with below cases its working
(xyz AND abcd)
((abc AND jkr) AND (3 OR 4))

but when i tried with below cases its not working
(xyz AND abcd efg)
((abc AND jkr) AND (3 OR 4 abcd))

0 Answers0