Substring

Block Group: String Operations
Icon:Substring block icon

The Substring block returns a specific substring from a string.

The block checks for parameters in the following order of importance:

  • A start character position and length
  • A start character position and end character position
  • An end character position and length

For information on using dataflow blocks, see Dataflow.


Input/Output Properties

The following properties of the Substring block can take input and give output.

  • input (string)
  • start (number)
  • length (number)
  • end (number)

input specifies the text string that contains the characters to extract.

start determines the position of the first character to extract. A value of 0 indicates the first character in the input.

length specifies the number of characters to extract.

end determines the position of the last character to extract.


Output Property

The following property of the Substring block can give output but cannot take input.

  • output (string)

output returns the substring.


Special Cases

The following are special cases for the Substring block:

  • If start, length, and end are null, the full input string is returned.
  • If start is greater than the length of input, the Substring block returns empty text.
  • If start plus length exceeds the length of input, the Substring block returns a substring that begins with start and ends with the end of the text.

Examples

The following image demonstrates two examples of the Substring block. The leftmost Substring block returns a four-character substring that begins with the character at position 0. The rightmost Substring block returns a substring that begins with the character at position 4 and ends with the character at position 9.

Substring block examplesl