title: Regex to match content between curly braces
body: <p>I have the following textfile and need to extract the text from the Element and Cluster matches. I'm using the following regular expression:</p>
  <pre><code>CLUSTER\[at....\][\d\D]+?{[\d\D]+?items[\d\D]+?}|(ELEMENT\[at....\][\d\D]+?}[\d\D]+?})
  </code></pre>
  <p>While this works fine, for some particular textfiles like this one below, where some elements will have more than one <code>DV</code> match, it won't extract the entire value matches section only the first element.</p>
  <p>For example <code>ELEMENT[at0030]</code> will leave out the <code>DV_TEXT</code> matches and <code>DV_PROPORTION</code> matches while <code>ELEMENT[at0028]</code> will match everything I need.</p>
  <p>I need my regular expression to be able to get everything inside the &quot;value matches&quot; curly braces of each <code>ELEMENT</code> not just the first value from here. Any help?</p>
  <p>Down here is an example of a textfile I'm working on:</p>
  <pre><code>definition
      CLUSTER[at0000] matches {    -- Examination of a cleavage-stage embryo
          items cardinality matches {1..*; unordered} matches {
              ELEMENT[at0028] occurrences matches {0..1} matches {    -- Number of cells
                  value matches {
                      DV_COUNT matches {*}
                  }
              }
              ELEMENT[at0030] occurrences matches {0..1} matches {    -- Fragmentation
                  value matches {
                      DV_CODED_TEXT matches {
                          defining_code matches {
                              [local::
                              at0031,    -- None
                              at0032,    -- Mild fragmentation
                              at0033,    -- Moderate fragmentation
                              at0034]    -- Severe fragmentation
                          }
                      }
                      DV_TEXT matches {*}
                      DV_PROPORTION matches {*}
                  }
              }
              ELEMENT[at0035] occurrences matches {0..1} matches {    -- Blastomere size
                  value matches {
                      DV_CODED_TEXT matches {
                          defining_code matches {
                              [local::
                              at0036,    -- Equal, stage specific
                              at0037,    -- Unequal, stage specific
                              at0053,    -- Equal, non-stage specific
                              at0054]    -- Unequal, non-stage specific
                          }
                      }
                      DV_TEXT matches {*}
                  }
              }
              ELEMENT[at0038] occurrences matches {0..1} matches {    -- Nucleation
                  value matches {
                      DV_CODED_TEXT matches {
                          defining_code matches {
                              [local::
                              at0039,    -- No visible nuclei
                              at0040,    -- Mononucleation
                              at0041,    -- Binucleation
                              at0051,    -- Multinucleation
                              at0052]    -- Broad multinucleation
                          }
                      }
                      DV_TEXT matches {*}
                  }
              }
              ELEMENT[at0042] occurrences matches {0..1} matches {    -- Cytoplasmic morphology
                  value matches {
                      DV_TEXT matches {*}
                  }
              }
              ELEMENT[at0043] occurrences matches {0..1} matches {    -- Spatial distribution of cells
                  value matches {
                      DV_TEXT matches {*}
                  }
              }
              ELEMENT[at0044] occurrences matches {0..1} matches {    -- Compaction
                  value matches {
                      DV_CODED_TEXT matches {
                          defining_code matches {
                              [local::
                              at0045,    -- None
                              at0046,    -- Minimal
                              at0047,    -- Moderate
                              at0048]    -- Complete
                          }
                      }
                      DV_TEXT matches {*}
                  }
              }
              ELEMENT[at0049] occurrences matches {0..*} matches {    -- Other morphological features
                  value matches {
                      DV_TEXT matches {*}
                  }
              }
              ELEMENT[at0055] occurrences matches {0..1} matches {    -- Morphology grade
                  value matches {
                      DV_TEXT matches {*}
                  }
              }
          }
      }
  
  
  ontology
      term_definitions = &lt;
          [&quot;en&quot;] = &lt;
              items = &lt;
                  [&quot;at0000&quot;] = &lt;
                      text = &lt;&quot;Examination of a cleavage-stage embryo&quot;&gt;
                      description = &lt;&quot;Morphological findings obtained by microscopy of the human cleavage-stage embryo.&quot;&gt;
                  &gt;
                  [&quot;at0028&quot;] = &lt;
                      text = &lt;&quot;Number of cells&quot;&gt;
                      description = &lt;&quot;Number of cells in a cleavage-stage embryo.&quot;&gt;
                  &gt;
                  [&quot;at0030&quot;] = &lt;
                      text = &lt;&quot;Fragmentation&quot;&gt;
                      description = &lt;&quot;Cytoplasmic fragmentation in a cleavage-stage embryo.&quot;&gt;
                      comment = &lt;&quot;The proportion data type can be used to record a more precise assessment.&quot;&gt;
                  &gt;
                  [&quot;at0031&quot;] = &lt;
                      text = &lt;&quot;None&quot;&gt;
                      description = &lt;&quot;Absence of cytoplasmic fragments.&quot;&gt;
                  &gt;
                  [&quot;at0032&quot;] = &lt;
                      text = &lt;&quot;Mild fragmentation&quot;&gt;
                      description = &lt;&quot;Cytoplasmic fragments cover &lt; 10% of the total cytoplasmic volume.&quot;&gt;
                  &gt;
                  [&quot;at0033&quot;] = &lt;
                      text = &lt;&quot;Moderate fragmentation&quot;&gt;
                      description = &lt;&quot;Cytoplasmic fragments cover 10 - 25% of the total cytoplasmic volume.&quot;&gt;
                  &gt;
  </code></pre>