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
  • 91,013
  • 29
  • 181
  • 233
ncohen
  • 6,936
  • 21
  • 70
  • 118

0 Answers0