If I want to capture e.g. text that is either in round brackets or square brackets and use this regular expression:
\[(.+)\]|\((.+)\)
I get for the example "[test]" the results "test" and "undefined" and for "(test)" the results "undefined" and "test". How can I manage to get only "test" as result?
(This regex is only an example, my actual regex is more complex but with the same problem.)