Can someone please help me in PHP to build a regex and parse the below string to achieve individual modules.
Examples of some string formats: ( ) => group
str1 = ( A && B ) || ( C || D ) && !( E || F )
O/P array = ( group1, || , group2, && , group3)
str2 = !( A || B ) && ( C || D ) && ( E && F )
O/P array = ( group1, && , group2, && , group3)
str3 = !( A || B )
O/P array = ( group1)
str4 = ( A && B )
O/P array = ( group1)
str5 = ( A || B )
O/P array = ( group1)
str5 = ( A && B )
O/P array = ( group1)
In short, these groups can be any order or there is no limit for the data within each group.
Group 1 : ( A && B && C &&......n )
Group 2 : ( A || B || C ||......n )
Group 3: !( A || B || C ||......n )
Thanks in advance. If needed then I can post what I have right now?
Answer which worked as of now: '/(!?\(.*?\))|\|\||&&/'
But it is giving me an error for below examples where there is just one group which is w/o parentheses:
str1 = A && B
O/P array = group1 (no parentheses) where group 1 = A && B
str2 = A || B || C
O/P array = group1 (no parentheses) where group 1 = A || B || C