The MID function returns a sub-string of the input string, starting from the specified offset.
| Input | Data Type | Description |
|---|---|---|
| Input1 | String | The original string. |
| Input2 | Integer | Sets the Offset property. (optional) |
| Input3 | Integer | Sets the Count property. (optional) |
| Output | Data Type | Description |
|---|---|---|
| Output1 | String | The sub-string. |
| Name | Property Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
| Offset | int | The character position the sub-string is to start from. The first character in the original string is position 1. | ||||||
| Count | int | The number of characters to include in the new string. Return empty string, if Count is set to 0. Return whole string, if Count is set to -1. |
||||||
| Mode | choice |
Specifies how to count the length.
|
||||||
| Encoding | choice | Specifies encoding when counting by bytes. |
When "Mode" property is set to Byte, the number of characters is calculated by byte of specified character encoding.
Represents the string "あいうえお" as a Shift JIS and UTF-8,
shift_jis: 82 A0 82 A2 82 A4 82 A6 82 A8
utf-8: E3 81 82 E3 81 84 E3 81 86 E3 81 88 E3 81 8A
For example, you specify "6" as a number of byte in Left function, outputs "あいう" when encoding is shift_jis. Outputs "あい" when encoding is utf-8.
If you specify "5", the output is truncated in both encodings. In this case, the string is truncated so that it can be less than specified number. Thus, "あい" (2 letters, 4 bytes) when encoding is shift_jis. "あ"(1 letter, 3 bytes) when encoding is utf-8
(Mid function, start position is shifted below when it is splitted in the letter.)
Note: The expected result is not aquired when the character encoding with ShiftIn/ShiftOut like iso-2022-jp.
Note: The expected result may be not auired when platform is AIX.
| Property | Output | |||
| Input1 | abcdefghijklmnop | Offset | 3 | cd |
| Count | 2 | |||