Regex remove middle portion of the string with look ahead
<p>I am trying to use sed to replace a few thousand strings I have.</p>

<p>I have strings like <code>('app','model.whatever.id')</code> or <code>('app','model.whatever.whateveragain.status')</code> or <code>('app','model.whatever.type').</code></p>

<p>I need to replace all instances of these strings to be like so:</p>

<pre><code>('app','model.id')
('app','model.status')
('app','model.type')
</code></pre>

<p>A few notes. I only need to match strings that start with <code>model.</code> or <code>whatevermodel.</code>, the middle can have 1 or multiple chunks, I need to retain the final piece of information ie <code>id</code>,<code>status</code> etc.</p>

<p>The code I currently have is:</p>

<pre><code>find /var/www/html/test2 -type f -print0 | xargs -0 sed -i '/.*model\..*\./{s//model./g}' 
</code></pre>

<p>This seems to work for most examples but in the case of <code>('app','model.whatever.type').</code> the final fullstop outside of the parenthesis causes an issue as the parenthesis is removed (I have instanced where the fullstop can occur 350 characters later so large chunks of the lines are being removed.</p>

<p>Forgive me as regex is not my strong suit, but I have attempted to use the following, but I am not getting the desired result. This was meant to match the last occurrence of a fullstop before a parenthesis.  </p>

<pre><code>find /var/www/html/test2 -type f -print0 | xargs -0 sed -i '/model\..*(?:(?!^.:[ ])[\s\S])*\\)/{s//model./g}'
</code></pre>

<p>Can anyone point me in the right direction as I feel I'm a few tweaks away from what i need.</p>