---
title: table.lookup_regex
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/table/table-lookup-regex
---

```
REGEX table.lookup_regex(ID id, STRING key)
```

**Available in:** all subroutines

Looks up the key `key` in the table `id`. When the key is present, its
associated value will be returned. When the key is absent, an
[unsatisfiable regex](https://www.fastly.com/documentation/reference/vcl/declarations/local-variables/)
will be returned.

## Example

```vcl
# Here we allow a different set of extensions per-path in the url.
# For example:
#   /articles/abc.png - wrong extension for the dirname
#   /images/abc.png   - this extension is allowed for /images
table t REGEX {
  "/images": "^(?:jpe?g|png)$",
  "/articles": "^md$",
}

sub vcl_recv {
  declare local var.re REGEX;
  set var.re = table.lookup_regex(t, req.url.dirname);
  if (req.url.ext !~ var.re) {
    error 403; # unexpected file extension
  }

  error 200;
}
```
