1

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 ].

Maroun
  • 94,125
  • 30
  • 188
  • 241
Nate
  • 7,606
  • 23
  • 72
  • 124

0 Answers0