---
title: regsuball
summary: null
url: https://www.fastly.com/documentation/reference/vcl/functions/strings/regsuball
---

```
STRING regsuball(STRING input, REGEX pattern, STRING replacement)
```

**Available in:** all subroutines

Replaces all occurrences of `pattern`, which may be a Perl-compatible regular
expression, in `input` with `replacement`. If no matches are found, no
replacements are made.

Once a replacement is made, substitutions continue from the end of the
replaced buffer. Therefore, `regsuball("aaa", "a", "aa")` will return a
string "aaaaaa" instead of recursing indefinitely.

This function may fail to make a replacement if the regular expression recurses
too heavily. Such a situation may occur with lookahead and lookbehind
assertions, or other recursing non-regular expressions. In this case,
`fastly.error` is set to `EREGRECUR`.

Groups captured with `pattern` can be used in the replacement string. Read the
`regsub` documentation for more information.

This function is not prefixed with the `std.` namespace.

## Errors

This function may fail to make a replacement if the regular expression
recurses too heavily. Such a situation may occur with lookahead and
lookbehind assertions, or other recursing non-regular expressions.
In this case, `fastly.error` is set to
`EREGRECUR`.

## Example

```vcl
set req.url = regsuball(req.url, "\+", "%2520");
```
