In this question a regex for capturing a string between delimiters is provided:
Test: This is a test string [more or less]
Regexp: (?<=\[)(.*?)(?=\])
Returns: more or less
What if the string to be captured also contains delimiters?
Test 1: This is a test string [more [or] less]
Return 1: more [or] less
Test 2: This is a test string [more [or [and] or] less]
Return 2: more [or [and] or] less
And multiple brackets?
Test 3: This is a test string [more [or [and] or] less] and [less [or [and] or] more]
Return 3: more [or [and] or] less
, less [or [and] or] more
Which regex would do this? Or which small ruby/python script can do this?