title: Regular Expression: Extract the lines
body: <p>I try to extract the name1 (first-row), name2 (second-row), name3 (third-row) and the street-name (last-row) with regex:</p>
  
  <pre><code>Company Inc.
  JohnDoe
  Foobar
  Industrieterrein 13
  </code></pre>
  
  <p>The very last row is the street name and this part is already working (the text is stored in the variable "S2").</p>
  
  <pre><code>REGEXREPLACE(S2, "(.*\n)+(?!(.*\n))", "")
  </code></pre>
  
  <p>This expression will return me the very last line. I am also able the extract the first row:</p>
  
  <pre><code>REGEXREPLACE(S2, "(\n.*)", "")
  </code></pre>
  
  <p>My problem is, that I do not know how to extract the second and third row....</p>
  
  <p>Also how do I test if the text contains one, two, three or more rows? </p>
  
  <p><strong>Update</strong>:</p>
  
  <p>The regex is used in the context of Scribe (a ETL tool). The problem is I can not execute sourcecode, I only have the following functions:</p>
  
  <ul>
  <li><code>REGEXMATCH(input, pattern)</code> </li>
  <li><code>REGEXREPLACE(input, pattern, replacement)</code></li>
  </ul>