# 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`.
