# Strings cut

## <img src="/files/HmwSJprK3GNLeDCEsyVv" alt="" data-size="line"> Strings cut

### Description <a href="#description" id="description"></a>

The Strings Cut transform cuts a portion of a string (i.e., a substring). If the designated field is out of range, it returns blank.

| Hop Engine | <sup>✓</sup> |
| ---------- | ------------ |
| Spark      | ?            |
| Flink      | ?            |
| Dataflow   | ?            |

### Options

| Option           | Description                                                                                                                                                                                |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Transform name   | Name of the transform.                                                                                                                                                                     |
| In stream field  | Name of the field whose substring to cut.                                                                                                                                                  |
| Out stream field | When a field name is given here, the transform creates a new field with the substring. Otherwise the original field gets replaced by the substring.                                        |
| Cut from         | Designate where to begin cutting the substring. This value is 0-based, thus the first character in a string is 0.                                                                          |
| Cut to           | Designate where to end cutting the substring. This value is exclusive (1-based), so using a 1 includes the first character. The maximum length of the new string is Cut to minus Cut from. |

### Examples

Consider the following string (displayed here with positive and negative length references):

```
|0        |10       |20       |30       |40
The quick brown fox jumps over the lazy dog
   |-40      |-30      |-20      |-10
```

The text above is considered as input string in all the following examples:

| Cut from | Cut to | Result                                        | Notes                                                                                                          |
| -------- | ------ | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| 0        | 9      | `The quick`                                   | Use `0` to refer to the first character                                                                        |
| 10       | 19     | `brown fox`                                   | Use two positive indexes to get a substring from the start of the input                                        |
| 0        | -12    | `the lazy dog`                                | Use a negative index to get a substring from the end of the input                                              |
| -13      | -23    | `jumps over`                                  | Use two negative indexes to get a substring from the end of the input                                          |
| 20       | 10     | (null)                                        | When the first index is lower than the second, `null` is returned                                              |
| 10       | 10     | (empty string)                                | When the two indexes are equal, an empty string (not `null`) is returned                                       |
| 20       | 100    | `jumps over the lazy dog`                     | When the second index is greater than the input length, the returned substring extends to the end of the input |
| 50       | 100    | (null)                                        | When the first index is greater than the input length, `null` is returned                                      |
| 10       | -10    | `The quick brown fox jumps over the lazy dog` | When the two indexes have different signs, the entire input is returned                                        |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.primeur.com/data-shaper-1.21/knowing-the-data-shaper-designer/pipelines/transforms/stringcut.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
