---
title: "substring Formula Function: Extract Part of a Text in Nodinite Search Fields"
description: The substring Formula function returns part of a text from a zero-based start index and a length, from the message body, a context property, or another function such as jsonPath.
---

# <i class="fal fa-function" aria-hidden="true"></i> Formula - substring

The `substring` [Formula][] function returns `length` characters of the content, starting at the zero-based `startIndex`.

![Keep only the date of an order with substring around jsonPath, animated walkthrough (7.12)][1]  
*Animated walkthrough: on the Order Received JSON of the [Order-to-Cash demo][], `jsonPath('$.orderDate', body)` returns the order date and time. Wrapped in `substring(0, 10, …)`, ten characters from the first one remain: the date only, such as `2026-11-15`.*  

## <i class="fal fa-code" aria-hidden="true"></i> Syntax

```text
substring(startIndex, length, content)
```

### Parameters

|Parameter|Required|Description|
|---|---|---|
|`startIndex`|Yes|The zero-based position of the first character to return; `0` is the first character. Write it as a number, without quotes.|
|`length`|Yes|The number of characters to return. Write it as a number, without quotes.|
|`content`|Yes|The text to take characters from: [body][], [context][], or the result of another function, such as [jsonPath][].|

### Returns

The part of the content from `startIndex` for `length` characters. When the content holds several values, each value is cut and returned as its own [Search Field][What is a Search Field] value.

## <i class="fal fa-list-ol" aria-hidden="true"></i> Examples

### Example 1: Take the first four characters of the message body

#### Input

```text
nodinte
```

#### Formula

```text
substring(0, 4, body)
```

#### Result

```text
nodi
```

![Test Expression tab: substring(0, 4, body) returns nodi][15]  
*Start index `0` is the first character, so four characters from the start are returned.*  

### Example 2: Take the first word of a context property

#### Input

|Key|Value|
|---|---|
|`id`|`Amazing Function`|

#### Formula

```text
substring(0, 7, context('id'))
```

#### Result

```text
Amazing
```

![Test Expression tab: substring(0, 7, context('id')) returns Amazing for the context value Amazing Function][17]  
*Seven characters from the start of the context value `Amazing Function`.*  

### Example 3: Take the first two characters of several jsonPath values

#### Input

```json
[
{ "name": "column" },
{ "name": "olive"}
]
```

#### Formula

```text
substring(0, 2, jsonPath('$..name', body))
```

#### Result

```text
co
ol
```

![Test Expression tab: substring on two jsonPath values returns co and ol][16]  
*`jsonPath` returns two values, and `substring` cuts each one: two unique matches.*  

## <i class="fal fa-circle-info" aria-hidden="true"></i> Notes

* A `startIndex` past the end of the text gives no value: `substring(10, 4, body)` on `nodinte` shows the warning *The Expression yields no result*.
* A `length` that runs past the end returns the rest of the text, without an error: `substring(4, 10, body)` on `nodinte` returns `nte`.

## <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-right-left" aria-hidden="true"></i> [replace][]  
* <i class="fal fa-code" aria-hidden="true"></i> [replaceregex][]  
* <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_Substring.gif
[15]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/substring_simplecontent.png
[16]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/substring_nestedContent.png
[17]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Alter/substring_simpleContent_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/
[replace]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/alter/replace/
[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/
[Test Your Expression]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/#test-your-expression
[What is a Search Field]:https://docs.nodinite.com/administration/log-management/search-fields/features/what-is-a-search-field/