title: regex lookahead problems in nginx
body: <p>I have a list of urls like this:</p>
  
  <pre><code>iphone-repair/iphone-4s-repair/iphone-4s-lcd-repair
  iphone-repair/iphone-4s-repair/iphone-4s-glass-repair
  iphone-repair/iphone-4s-repair/iphone-4s-glass-amp-lcd-replacement
  </code></pre>
  
  <p>I want to rewrite them like this:</p>
  
  <pre><code>iphone-repair/iphone-4s-repair/iphone-4s-screen-repair
  </code></pre>
  
  <p>I got it working like this:</p>
  
  <pre><code>rewrite ^(.*?)-(glass|glass-.*?lcd|lcd)-.*?(replacement|repair)(.*?)  https://${server_name}$1-screen-repair$5 last;
  </code></pre>
  
  <p>The problem is there are also urls like this:</p>
  
  <pre><code>iphone-repair/iphone-4s-repair/iphone-4s-front-glass-amp-lcd-amp-back-glass-replacement
  </code></pre>
  
  <p>on which we do <em>NOT</em> want any rewrites to happen.</p>
  
  <p>So have been banging my head against the keyboard trying to understand how to get a lookbehind to abort the ENTIRE match if the word "front" appears.</p>
  
  <p>I tried this </p>
  
  <pre><code>^(.*?)-(?&lt;!front-)(glass|glass-.*?lcd|lcd)-.*?(replacement|repair)(.+)?
  </code></pre>
  
  <p>but it does not seem to abort the entire match...</p>
  
  <p>any help really appreciated!!</p>