Swift replace full line in String
<p>I have multiple lines in an String, for example:</p>

<pre><code>let str = "Mieter: Hannes Tester \nVerwalter: Michael Karner \n"
</code></pre>

<p>Now i want to remove the whole sentence between "Mieter" and the line break. So the result should be:</p>

<pre><code>let str = "Verwalter: Michael Karner \n"
</code></pre>

<p>I could check with Regex, but i am only able to get the string between 2 words. For example with:</p>

<pre><code>if let match = str.rangeOfString("(?&lt;=Mieter)[^\n]+", options: .RegularExpressionSearch) {
    print(str.substringWithRange(match)) // between
}
</code></pre>

<p>But how can i replace a whole line? </p>

<p><strong>Edit:</strong> </p>

<p>It is not working anymore when its between a string:</p>

<pre><code>let str = "Test \n Mieter: \n Hausverwalter: \n Firma: \n"

str.stringByReplacingOccurrencesOfString("^Mieter[^\n]+\\s", withString: "", options: .RegularExpressionSearch, range: nil)

// so "Mieter \n" is not being replaced.
</code></pre>