In PHP I have the following regex to match words that are between [] or {} :
\[([^\]]*)\]|\{([^\}]*)\}
When using this on this text :
xyz[word1]abc[word2]def{word4}ghi[word5]jkl{word6}mno
with
preg_match_all('/\[([^\]]*)\]|\{([^\}]*)\}/i', 'xyz[word1]abc[word2]def{word4}ghi[word5]jkl{word6}mno', $result);
I get an array that contains 3 arrays, with the 2 different capture groups as 2 different arrays.
The regex is a simple example to illustrate the question, so simplyfying the regex to use only 1 capture group is not an option. I must have 2 different capture groups but need them only in 1 result array.
So, is there any way to combine multiple capture groups into 1 capture-result array ?