---
title: std.replace_suffix
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/strings/std-replace-suffix
---

```
STRING std.replace_suffix(STRING s, STRING target, STRING replacement)
```

**Available in:** all subroutines

Replaces the last occurrence of the string `target` in string `s` with `replacement`
if `s` ends with the target string.

This corresponds to `std.suffixof(s, target)` returning `true`. If `target` is 
the empty string, the original string `s` is returned.

## Example

```vcl
# Strip trailing slashes from the request URL
set req.url = std.replace_suffix(req.url, "/", "");
```
