0

Given lines such as:

[{ ERR }]
 { ABC }
 [ NT1 ]

 [ XYZ }  <- This is an illegal form and should also be ignored

How do I write a regex that will capture the first segment, but ignore the others if I read line by line. So if there is one nested pair of [] and one pair of {} it will match that, and then not match on the other lines.

I've attempted to do this using the expression ([ \[]*([ \{]*[a-zA-Z]+[ \} ]*)[ \] ]*)

I'm also trying to output the three alphanumerics in the center as a match subgroup (there will never be more than three char). Whitespace is irrelevant.

Integration
  • 185
  • 8

0 Answers0