php - How do I create a regular expression to capture {this} text and exclude \{that}? -


I need a regular expression to capture field names in the string. They are listed among my requirements:

  1. Field names in crisp brace
  2. No spaces in the field names
  3. Curly braces \ < / Li>

then in the following:

  capture {this} text and out \ {that}?  

Matches are {it}, but not {that}.

I am using PHP and preg_match (I can use a FIFF function, I am open to it)

Any thoughts? I care about explaining the result for this, so I can learn something :)

  $ s = 'Capture {this} text and out \ {that} {a} \ {b} {c}?'; Preg_match_all ('~ (? & Lt;! \\\) {[^}] +} ~, $ s, $ match); Var_dump (matches $);  

In the description, you can read about negative perception (?


Comments