<p>I'm using Kubernetes with Istio which comes with traffic management. All backend api endpoints starts with <code>/api/**</code> followed by specific uri except frontend service. Frontend service has no any general uri prefix.</p>

<p>What i want to achieve is in the istio <code>VirtualService</code> use a regular expression that basically says, if a requested uri does not start with <code>/api/</code>, let it be served by frontend-service.</p>

<p>This is my <code>VirtualService</code></p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: {{ .Release.Name }}-frontend-ingress
  namespace: default
spec:
  hosts:
  {{ include "application.domain" . }}
  gateways:
  - iprocure-gateway
  http:
  - match:
    - uri:
        regex: '^(?!\/api\/).*'
    route:
    - destination:  
        host: {{ printf "%s.%s.svc.cluster.local" .Values.frontendService.serviceName .Release.Name }}
        port:
          number: {{ .Values.frontendService.service.port }}
</code></pre>

<p>What is the <code>regex</code> value that I can use to make all request that does not start with <code>/api/</code> be served with frontend-service</p>

<p>See  <a href="https://istio.io/news/releases/1.4.x/announcing-1.4/upgrade-notes/" rel="nofollow noreferrer">Istio 1.4.x upgrade notes</a> under the heading "Regex engine changes".  Envoy has moved to the Google Re2 "safe" regex engine which doesn't support negative look-ahead. An opt-out via an environment variable to Pilot is possible but will be removed in future versions.  I've yet to find a long-term solution to this other than writing long regexs.</p>

<p>For your particular case try</p>

<pre><code>regex: "^/((a$)|(ap$)|(api$)|([^a].*)|(a[^p].*)|(ap[^i].*)|(api[^/].*))"
</code></pre>
