MID

The MID function returns a sub-string of the input string, starting from the specified offset.

Input/Output

Number of Connections: Min: 1/Max:3
InputData TypeDescription
Input1StringThe original string.
Input2IntegerSets the Offset property. (optional)
Input3IntegerSets the Count property. (optional)

OutputData TypeDescription
Output1StringThe sub-string.

Property

NameProperty TypeDescription
OffsetintThe character position the sub-string is to start from. The first character in the original string is position 1.
CountintThe 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.
Modechoice Specifies how to count the length.
String - Count by the number of characters.
Binary - Count by the number of bytes.
EncodingchoiceSpecifies encoding when counting by bytes.

Topic

Handling of the number of characters when the unit is a number of 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.

Example

PropertyOutput
Input1abcdefghijklmnopOffset3cd
Count2