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

# <i class="fal fa-function" aria-hidden="true"></i> 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`.*  

## <i class="fal fa-code" aria-hidden="true"></i> 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.

## <i class="fal fa-list-ol" aria-hidden="true"></i> 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.*  

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* <i class="fal fa-magnifying-glass-plus" aria-hidden="true"></i> [Add or manage Search Field][]  
* <i class="fal fa-flask" aria-hidden="true"></i> [Test Your Expression][]  
* <i class="fal fa-hard-drive" aria-hidden="true"></i> [Add or manage Log View][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

* <i class="fal fa-link" aria-hidden="true"></i> [concat][]  
* <i class="fal fa-eraser" aria-hidden="true"></i> [removebom][]  
* <i class="fal fa-code" aria-hidden="true"></i> [replaceregex][]  
* <i class="fal fa-scissors" aria-hidden="true"></i> [substring][]  
* <i class="fal fa-function" aria-hidden="true"></i> [Formula][]  
* <i class="fal fa-scroll" aria-hidden="true"></i> [Formula language rules][]  
* <i class="fal fa-puzzle-piece" aria-hidden="true"></i> [Search Field Expressions][]  

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/Formula_Replace.gif
[19]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/replaceSimpleparameter_body.png
[20]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/replace_nestingParameter-body.png
[21]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/replace_simpleParameter_messageContext.png

[Add or manage Log View]:https://docs.nodinite.com/administration/log-management/log-views/features/add-or-manage-log-view/
[Add or manage Search Field]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/
[body]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/body/
[concat]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/alter/concat/
[Context]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/context/
[Formula]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/
[Formula language rules]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/#fa-scroll-formula-language-rules
[jsonPath]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/jsonpath/
[Order-to-Cash demo]:https://docs.nodinite.com/repository-model/bpms/examples/order-to-cash/generate-o2c-demo-data/
[removebom]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/alter/removebom/
[replaceregex]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/alter/replaceregex/
[Search Field Expressions]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/
[substring]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/alter/substring/
[Test Your Expression]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/#test-your-expression