---
title: REGEX
summary: null
url: https://www.fastly.com/documentation/reference/vcl/types/regex
---

A type representing a regular expression.

In Fastly VCL, regular expressions are handled using ahead-of-time compilation.
This means that values for the REGEX type must come from constant strings,
and they cannot be constructed (e.g., from a string variable) at runtime.

A REGEX value may be converted to a string either by assignment or implicitly.
This is a one-way conversion, because the regex itself is constant.
For example:

```vcl
declare local var.re REGEX;
set var.re = "^ab?c$";

set resp.http.a = "re = /" + var.re + "/"; # "re = /^ab?c$/"
set resp.http.b = std.toupper(var.re); # "^AB?C$"
log var.re; # logs "^ab?c$"
```
