Get characters which are not in brackets REGEX

45 views Asked by At

I'm basically working on custom query building. I've designed the pattern as field_set and sub_field_sets. A sample Query:

({e:3}.{f:44}.{f:2}) + ( 
                   ({e:3}.{f:44}.{f:3}) + ({e:3}.{f:44}.{f:4}) 
                        ) - ({e:3}.{f:44}.{f:5})

I want to get all operators from root using REGEX. Which in this case should result ['+', '-'] and NOT ['+', '+', '-']

1

There are 1 answers

2
Khazul On

This works on given sample:

([+-])(?![^+)-]+\)\s*\))