NexJ Logo

Sub()

Returns text from anywhere in a string using the specified start and end positions. This function takes a string and two integer values as arguments and returns a string value. The positions of characters in a string are numbered from the left starting at zero. For example, the position before the first character is 0, and the position between the first and second character is 1.

Syntax

Sub(<text_to_trim>, <start_position>, <end_position>)

Input

text_to_trim

string

The text to take characters from.

start_position

integer

The position to start taking characters from in the text.

end_position

integer

The position to stop taking characters from in the text.

Output

string

Examples

  • The expression Sub("The quick brown fox", 0, 3) returns "The".
  • The expression Sub("The quick brown fox", 10, 19) returns "brown fox".