---
title: "replace — Search and replace"
description: "iXML command replace: Search and replace."
canonical_url: "https://www.zeyos.com/ixml/ref/replace"
markdown_url: "https://www.zeyos.com/ai/guide/ixml/ref/replace.md"
section: "ixml-reference"
authority: "reference"
language: "en"
source_repository: "https://cloud.zeyos.com/__doc/ixmldoc.xml"
source_sha256: "a23f04e6a98628ca3c273c3b8dd2c33c034cfda3e0f00478d8793074fd2f70dd"
---

# replace — Search and replace

REPLACE searches a subject for occurrences of a given search value or matches to a given search pattern and replaces them with a given replacement value. The number of actual replacements is assigned to 'var_count'.

The replacement value of a regular expression may contain backreferences of the form '\n'. Every such reference will be replaced by the text captured by the n'th parenthesized pattern. '\0' always refers to the text matched by the entire search pattern.

### Attributes
| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| var | var |  | Result variable name |
| var_count | var |  | Result variable name for number of replacements |
| replacement | string |  | Replacement value |
| limit | int | (no limit) | Limit |

### Children
- (none)

### Parents
- (not restricted in the reference)

### Result
- binding: var; type: string

### Examples

```xml
<output>
	<replace value="Bill Gates" replacement="William Henry Gates III">My name is Bill Gates!</replace>
</output>

<!-- My name is William Henry Gates III! -->
```

```xml
<output>
	<replace pattern="/B[il]+\s*G\w+/" replacement="William Henry Gates III">My name is Bill Gates!</replace>
</output>

<!-- My name is William Henry Gates III! -->
```

```xml
<output>
	<replace pattern="/Bill ([a-z]+)/i" replacement="William Henry \1 III, call me \0">My name is Bill Gates!</replace>
</output>

<!-- My name is William Henry Gates III, call me Bill Gates! -->
```
