---
title: "gsql_replace()"
component: "gsql-ref"
version: "4.3"
module: "ddl-and-loading"
html_url: "/gsql-ref/4.3/ddl-and-loading/functions/token/gsql_replace"
canonical_url: "https://www.tigergraph.com/docs/gsql-ref/4.3/ddl-and-loading/functions/token/gsql_replace"
markdown_url: "https://www.tigergraph.com/docs/gsql-ref/4.3/ddl-and-loading/functions/token/gsql_replace.md"
---

[View as HTML](https://www.tigergraph.com/docs/gsql-ref/4.3/ddl-and-loading/functions/token/gsql_replace)

# gsql_replace()

Replaces all occurrences of a token (substring) in a string with a new token. If a max count is provided, there can only be up to that many replacements starting from the left side of the string.

## Syntax

`gsql_replace(str, old_token, new_token [, max])`

## Parameters

str

Required. The original string.

old\_token

Required. The token in the original string to replace.

new\_token

Required. The new token to replace the original token.

max

Optional. The maximum number of occurrences that the old token can be replaced.

## Return type

`STRING`

## Example

gsql_replace("hello world", l, i, 2) -> "heiio world"
