--- title: "Substring" slug: "core-sub-string-resolver" updated: 2026-04-16T11:54:29Z published: 2026-04-16T11:54:29Z canonical: "docs.lobstersoftware.com/core-sub-string-resolver" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # Substring > [!NOTE] > Value resolver – Abstract > > **Purpose:** Returns a continuous section (*substring*) of the string passed as *input value*. > > > [!TIP] > > Tooltip > > > > - **Usage**: The **Begin index** and **Max. length** parameters define the portion of the string in the input value that is returned. > > - **Parameter**: The **Begin index** and **Max. length** parameters can be determined by direct input or by a value resolver.. > > - A **Begin index** >=0 indicates the offset from the beginning of the string in the *input value* from which the desired *section* extends to the right. > > - A **Begin index** <0 indicates the offset to the end of the string in the *input value* from which the desired *section* extends to the left. > > - A **Max. length** >0 defines an upper limit for the number of characters returned as a section. > > - With **Max. length** =0 the *section* includes all characters *up to* the beginning or end of the string returned, depending on the **Begin index**. > > - **WARNING:** If values <0 are assigned for the **Max. length**, an error occurs. ![images/download/attachments/106957538/image2022-6-27_12-42-47-version-1-modificationdate-1656326567202-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image2022-6-27_12-42-47-version-1-modificationdate-1656326567202-api-v2.png) The [Substring](/v1/docs/en/core-sub-string-resolver) value resolver returns a continuous section (*Substring*) of the string passed as *input value*. The **Begin index** and **Max. length** parameters define the position and the (maximum) length of the returned section. - If no value (`$null`) is present as *input valu*e, no value (`$null`) is returned. - For *input values* that are not *strings*, their *string* mapping is processed. ## Configuration | Parameter | Value range | Meaning | | --- | --- | --- | | **Begin index** *(default: 0)* | >=0 | Index counts from left to right; `0` points to the first character of the *input value* | | <0 | Index counts from right to left; `-1` points to the last character of the *input value* | | **Max. Length** *(default: 0)* | 0 | "All" (any number of) characters starting from the line item defined by the **Begin index** | | >0 | Maximum number of characters from the item defined by **Begin index** | | <0 | Error (`Process Exception: String index out of range`) | Both parameters can be set by *direct input* (as a positive or negative integer) or via a value resolver at runtime. | In the example on the right, the value `-10` was entered directly for the **Begin index**. The returned section therefore starts with the tenth character from the end of the string passed as the *input* *value*. For the **Max. length** parameter, a [Variable](/v1/docs/en/core-storage-value) value resolver is used so that at runtime the value of the `maxCharacters` variable is used to limit the length of the section **NOTE:** Starting from the direct input provided by default, the definition of a value resolver must be initiated by clicking on the small gray arrow at the bottom left of the input value (see **Begin** **index** in the screenshot). If "no value" (from the context menu) is selected instead of a value resolver, the direct input appears again the next time the [Substring](/v1/docs/en/core-sub-string-resolver) value resolver is expanded. | ![images/download/attachments/106957538/image2022-6-27_12-44-7-version-1-modificationdate-1656326647078-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image2022-6-27_12-44-7-version-1-modificationdate-1656326647078-api-v2.png) | | --- | --- | ## Examples ### Examples of parameterization The following table illustrates the effect of the substring value resolver with different parameters using the example of the string `SCMU3216083 BLU/WHT 40ft` as *input value* (11-digit BIC code of a container followed by a space and then description text): | Begin index | Max. Length | Result | Comment | | --- | --- | --- | --- | | 0 (or: no value) | 0 (or: no value) | `SCMU3216083 BLU/WHT 40ft` | All characters | | 0 (or: no value) | 3 | `SCM` | Owner (first three characters of the container number) | | 12 | 0 (or: no value) | `BLU/WHT 40ft` | Description (any number of characters from 13th character) | | 10 | 1 | `3` | Check digit (at the end of the container number, i.e. 11th character) | | -4 | 0 (or: no value) | `40ft` | *Here*: Container type (convention: "last 4 characters") | | -4 | 2 | `40` | *Here*: Digits for length of the container in feet (according to convention) | | -80 | 0 (or: no value) | `SCMU3216083 BLU/WHT 40ft` | The last 80 characters → "all" if less than 81 characters | | 0 (or: no value) | 80 | `SCMU3216083 BLU/WHT 40ft` | The first 80 characters → "all" if less than 81 characters | ### More complex configuration example The readability of a string that combines the BIC code of a container with a description text of undefined length, as in the example above, is improved by inserting spaces between the segments within the container number. Runtime example: ![images/download/attachments/106957538/image2022-6-27_11-57-17-version-1-modificationdate-1656323837618-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image2022-6-27_11-57-17-version-1-modificationdate-1656323837618-api-v2.png) **NOTE:** The following configuration demonstrates the use of the [Substring](/v1/docs/en/core-sub-string-resolver) value resolver in the context of a loop with dynamic assignments for the parameters. The desired "segmentation" of the string can also be achieved using the [Replace text](/v1/docs/en/core-replace-string-resolver) value resolver via a regular expression. Configuration: | To make it as easy as possible to adjust the "segmentation" of the string as needed, the following configuration defines the desired length of the segments in question using a static string that can be interpreted as an array of integers in the JSON notation: [`3,1,6,1,0`] The value 0 at the last position means that *all* characters after the 11-digit (3+1+6+1) container number should be output. The [JSON to object](/v1/docs/en/core-json-decode-resolver) value resolver generates a list of integers from the static text, which can be processed in the header of a [For each loop](/v1/docs/en/core-for-each-entity-actor) in the **Resolver for entities** parameter. In the loop header, the **Save String in variable** parameter specifies that the *input value* (the string to be structured) is stored in the `input` variable. This variable allows access to the string within one iteration of the loop. The screenshot on the right shows a [Set value](/v1/docs/en/core-set-value-actor) event action in the action block for iteration, which is used to successively build the structured string for output in the `output` variable. For this purpose, a [Concat strings](/v1/docs/en/core-concat-string-resolver) value resolver is used (right), which appends another [Substring](/v1/docs/en/core-sub-string-resolver) from the variable `input` to the previous content of the variable `output` with each iteration. The parameters in the [Substring](/v1/docs/en/core-sub-string-resolver) value resolver change for each iteration: - The **Begin index** is read from a `cursor` variable, which is recalculated in the following step per iteration. - As **Max. length** is the integer from the array defined in the loop header that is valid as the *reference object* for the respective iteration and that is returned by the [Object property](/v1/docs/en/core-property-resolver) value resolver without specifying a field. A space is inserted before each "attachment" from the `input` variable (see position 2 in the [Concat strings](/v1/docs/en/core-concat-string-resolver) value resolver). To eliminate excess spaces, the [Trim](/v1/docs/en/core-trim-string-resolver) value resolver is concatenated in two places: - When concatenated with the [Substring](/v1/docs/en/core-sub-string-resolver) value resolver, the "inner" [Trim](/v1/docs/en/core-trim-string-resolver) value resolver prevents a double space from appearing in the `output` before the description text, which is already separated by a space in the `input`. - The "outer" [Trim](/v1/docs/en/core-trim-string-resolver) value resolver below the [Concat strings](/v1/docs/en/core-concat-string-resolver) is essentially used to eliminate the leading space before the first segment, which occurs because the `output` variable in the first iteration does not yet contain a character. | ![images/download/attachments/106957538/image2022-6-27_12-46-59-version-1-modificationdate-1656326819696-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image2022-6-27_12-46-59-version-1-modificationdate-1656326819696-api-v2.png) | | --- | --- | | The `cursor` variable is used to define the starting point for each next iteration. This achieves another [Set value](/v1/docs/en/core-set-value-actor) event action, in which the number of characters taken over in the current iteration (see the `segment` variable in the [Calculate value](/v1/docs/en/core-calculate-value-resolver) value resolver) is added to the previous `cursor` value. The "value" of this sum defines the **Begin** **index** for the next section to be copied. It is assigned to the `cursor` variable. **IMPORTANT:** The `output` and `cursor` variables used in the loop should be initialized with the `$null` and 0 values, respectively, before the start of the loop, otherwise "presets" of these variables can falsify the result. | ![images/download/attachments/106957538/image2022-6-27_12-48-0-version-1-modificationdate-1656326880862-api-v2.png](https://cdn.document360.io/4be90b94-ec83-41d8-963e-962df16110d4/Images/Documentation/image2022-6-27_12-48-0-version-1-modificationdate-1656326880862-api-v2.png) |