I'm trying to capture all the occurrences between two characters for example "["
and "]"
. However, I need the last occurrence of the first character and the first occurrence of the last character. Meaning that:
hello I'm [ a tricky [ test ] and another one [ here ]. goodbye
should return [ test ]
and [ here ]
.
I've tried this: /\[(.*?)\]/g
but it returns: [ a tricky [ test ]
and [ here ]
.