---
title: "replace Formula Function: Replace Text in Nodinite Search Fields"
description: The replace Formula function replaces every occurrence of a text with a new value in the message body, a context property, or the result of another function such as jsonPath.
---

# :fa-function: Formula - replace

The `replace` [Formula][] function returns the content with every occurrence of `oldValue` replaced by `newValue`.

![Strip the ORD- prefix from an order id with replace, animated walkthrough (7.12)][1]  
*Animated walkthrough: on the Order Received JSON of the [Order-to-Cash demo][], `replace('ORD-', '', jsonPath('$.orderId', body))` removes the prefix from `ORD-10005` and returns `10005`.*  

## :fa-code: Syntax

```text
replace('oldValue', 'newValue', content)
```

### Parameters

|Parameter|Required|Description|
|---|---|---|
|`'oldValue'`|Yes|The text to find. It's matched as plain text, not as a pattern, and case-sensitive: `'order'` doesn't replace `Order`. Use [replaceregex][] for patterns.|
|`'newValue'`|Yes|The text to substitute. Use `''` to remove `oldValue`.|
|`content`|Yes|The text to change: [body][], [context][], or the result of another function, such as [jsonPath][].|

### Returns

The content with all occurrences replaced. Content that doesn't contain `oldValue` is returned unchanged. When the content holds several values, the replacement runs on each value.

## :fa-list-ol: Examples

### Example 1: Replace a word in the message body

#### Input

```text
nodinite
```

#### Formula

```text
replace('nodinite','The worlds most innovative product',body)
```

#### Result

```text
The worlds most innovative product
```

![Test Expression tab: replace on the message body nodinite returns The worlds most innovative product][19]  
*The whole body matches `oldValue`, so the result is `newValue` only.*  

### Example 2: Replace a word in a context property

#### Input

|Key|Value|
|---|---|
|`id`|`nodinite`|

#### Formula

```text
replace('nodinite','The worlds most innovative company',context('id'))
```

#### Result

```text
The worlds most innovative company
```

![Test Expression tab: replace on the context value nodinite returns The worlds most innovative company][21]  
*The value of the context property `id` is changed; the message body isn't used.*  

### Example 3: Replace a word in several jsonPath values

#### Input

```json
[{ "name": "Amazing Function" }, { "name": "Amazing Implementaion" }]
```

#### Formula

```text
replace('Amazing','Cool',jsonPath('$..name', body))
```

#### Result

```text
Cool Function
Cool Implementaion
```

![Test Expression tab: replace on two jsonPath values returns Cool Function and Cool Implementaion][20]  
*`jsonPath` returns two values, and `replace` changes `Amazing` in each one: two unique matches.*  

## :fa-hand-point-right: Next Steps

* :fa-magnifying-glass-plus: [Add or manage Search Field][]  
* :fa-flask: [Test Your Expression][]  
* :fa-hard-drive: [Add or manage Log View][]  

## :fa-link-horizontal: Related Topics

* :fa-link: [concat][]  
* :fa-eraser: [removebom][]  
* :fa-code: [replaceregex][]  
* :fa-scissors: [substring][]  
* :fa-function: [Formula][]  
* :fa-scroll: [Formula language rules][]  
* :fa-puzzle-piece: [Search Field Expressions][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/Formula_Replace.gif
[19]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/replaceSimpleparameter_body.png
[20]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/replace_nestingParameter-body.png
[21]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/replace_simpleParameter_messageContext.png

[Add or manage Log View]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Add%20or%20Manage%20Log%20View.md
[Add or manage Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md
[body]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/body.md
[concat]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Alter/concat.md
[Context]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/context.md
[Formula]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md
[Formula language rules]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md#fa-scroll-formula-language-rules
[jsonPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/jsonPath.md
[Order-to-Cash demo]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Generate-O2C-Demo-Data.md
[removebom]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Alter/removebom.md
[replaceregex]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Alter/replaceregex.md
[Search Field Expressions]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md
[substring]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Alter/substring.md
[Test Your Expression]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md#test-your-expression