addEventListener("fetch", event => {
  // Get the request from the client.
  const req = event.request;

  // Capture a group with brackets
  let reg = new RegExp ("\/status\/(\\d+)","i");
  let matches = req.url.match(reg);
  console.log(matches[1]);

  // Non-capturing groups can be created by prefixing the bracketed expression with ?:
  reg = new RegExp ("(\?:\/status\/)(\\d+)","i");
  matches = req.url.match(reg);
  console.log(matches[1]);

  // Bracketed character class with [...]
  reg = new RegExp ("&?aaa=([^&]*)");
  matches = req.url.match(reg);
  console.log(matches[1]);

  // Specific repeat count with {x}
  // Alternate options using (a|b)
  // Do not capture bracketed items if prefixed by ?:
  reg = new RegExp ("&?b{3}=(foo|bar)(?:$|&)");
  matches = req.url.match(reg);
  console.log(matches[1]);

  // Make the match case insensitive using "i"
  reg = new RegExp ("(AaA=Foo)","i");
  matches = req.url.match(reg);
  console.log(matches[1]);

  // Send the request to `origin_0`.
  const backendResponse = fetch(req, {
    backend: "origin_0"
  });

  // Send the backend response back to the client.
  event.respondWith(backendResponse);

  // This is a minimal Compute@Edge app in JavaScript.  For alternative starter
  // code for your fiddle, see the code examples on our developer hub:
  // https://developer.fastly.com/solutions/examples/javascript/
});