> For the complete documentation index, see [llms.txt](https://docs.inforiver.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inforiver.com/formula-syntax/text-formatting-functions/replace.md).

# REPLACE

Replaces part of a text string with different text based on the position and number of characters you specify.

The REPLACE function replaces an input text string with a given value for a specified index and length. Node references are also accepted as arguments. The index starts at 1 i.e. the first character of the input string will have an index of 1.&#x20;

### Syntax

```javascript
replace(old_string:string, index:number, length:number, replace_text:string)
```

### Arguments

old\_string- A text string.Required.&#x20;

index- A number indicating the position at which the string should be replaced.Required.&#x20;

length- A number indicating the number of characters to be replaced in the input string.Required.&#x20;

replace\_text- A text string that will replace a part/all of the old\_string parameter.Required.

### Example

```javascript
REPLACE('INFORIVER', 1, 4, 'LUMEL')
//Returns “LUMELRIVER"
```

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FZOg76Z4EcdAQdiKuJb2L%2Fimage.png?alt=media&amp;token=02cbdeba-df48-4841-86b2-46aada339025" alt=""><figcaption><p>Replace function</p></figcaption></figure>

### **Excel equivalent**

[**Replace**](https://support.microsoft.com/en-us/office/replace-function-8d799074-2425-4a8a-84bc-82472868878a)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.inforiver.com/formula-syntax/text-formatting-functions/replace.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
