# replace-values-in-text

## Description

The <mark style="color:purple;">`replace-values-in-text`</mark> *adaptor replaces all instances of a pattern in a text with specified replacement text.*

Searches a text value for a specific pattern, and replaces one or all matches with a replacement text. The pattern can be a text or a regular expression. If pattern is a text, only the first occurrence will be replaced. If pattern is a regular expression ([RegEx](https://regex101.com/)), all occurrences will be replaced.

## Inputs

**`text`**\
Type: `text`\
Required: Yes\
The text containing values to be replaced.

**`pattern`**\
Type: `text`\
Required: Yes\
The text or regular expression to be replaced. The pattern is treated as a regular expression if it begins and ends with `/` (e.g., `/.*/`).

**`replacement`**\
Type: `text`\
Required: No\
The text that replaces all instances of the `pattern`. If unspecified, matches will be replaced with  blank text. If a regular expression is used as a pattern, capture groups can be included as `$` followed by the number of the group (e.g., `$1` for the value of the first group).

## Outputs

**`text`**\
Type: `text`\
A modified text.

## Examples

### Example 1: Default behaviour.

Inputs:

`text`: Oxford had a population of 162,100 at the 2021 census

`pattern`: 2021

`replacement`: 2020

#### Outputs:

`text`: Oxford had a population of 162,100 at the 2020 census

-> Replaced the value `2021` in the text with the value `2020`.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cgps.gitbook.io/data-flo/reference-guide/replace-values-in-text.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
