title: Python - How to find and save all word between two specific strings
body: <p>while searching I found this <a href="https://stackoverflow.com/questions/13746721/using-re-to-capture-text-between-key-words-over-the-course-of-a-doc">threat</a>. This is quiet close to what I need.</p>
  <p>Which leads directly to my first Problem:</p>
  <p>The string I have is:</p>
  <pre><code>line = &lt;draw:line draw:style-name=&quot;gr1&quot; draw:text-style-name=&quot;P1&quot; draw:layer=&quot;layout&quot; svg:x1=&quot;0cm&quot; svg:y1=&quot;0cm&quot; svg:x2=&quot;3.5cm&quot; svg:y2=&quot;2.7cm&quot;&gt;
  </code></pre>
  <p>I need to extract the values after the svg:x1= tags. So I tried</p>
  <pre><code>print re.findall(r&quot;(?&lt;=svg:x1) (.*?) (?=svg:y1)&quot;, line)
  </code></pre>
  <p>But nothing except [] is printed.</p>
  <p>The second Problem is I then tried something like</p>
  <pre><code>line = 'string1 string2 string3'
  </code></pre>
  <p>and then</p>
  <pre><code>print re.findall(r&quot;(?&lt;=string1) (.*?) (?=string3)&quot;, line)
  </code></pre>
  <p>which gives what I want, but when I try</p>
  <pre><code>file.write(re.findall(r&quot;(?&lt;=string1) (.*?) (?=string3)&quot;, line))
  </code></pre>
  <p>(The file I want to write to is of course defined before, so I can write stuff to it)</p>
  <p>I get &quot;TypeError: expected a character buffer object&quot;</p>
  <p>So now my question in one complete sentence:<br />
  How can I extract a string between to specific strings and save it in a file?</p>