title: How to extract text part from file using Python & Regular Expressions
body: <p>Using Python I want to read a text file, search for a string and print all lines between this matching string and another one.</p>
  
  <p>The textfile looks like the following:</p>
  
  <pre><code>Text=variables.Job_SalesDispatch.CaptionNew
      Tab=0
      TabAlign=0
      }
     }
    }
  [UserVariables]
   User1=@StJid;IF(fields.Fieldtype="Artikel.Gerät"  , STR$(fields.id,0,0)  , @StJid)
  [Parameters]
   [@Parameters]
    {
    [Parameters]
     {
     LL.ProjectDescription=? (default)
     LL.SortOrderID=
     }
    }
  [PageLayouts]
   [@PageLayouts]
    {
    [PageLayouts]
     {
     [PageLayout]
      {
      DisplayName=
      Condition=Page() = 1
      SourceTray=0
  </code></pre>
  
  <p>Now I want to print all "UserVariables", so only the lines between <code>[UserVariables]</code> and the next line starting with a square bracket. In this example this would be <code>[Parameters]</code>. </p>
  
  <p>What I have done so far is:</p>
  
  <pre class="lang-py prettyprint-override"><code>with open("path/testfile.lst", encoding="utf8", errors="ignore") as file:
  
    for line in file:
      uservars = re.findall('\b(\w*UserVariables\w*)\b', line)
      print (uservars)
  </code></pre>
  
  <p>what gives me only <code>[]</code>.</p>