Previous Up Next

5.4.4  The left and right parts of a string: left right

The left command takes two arguments, a string s and a non-negative integer n.
left returns the first n characters of the string.
Input:

left("hello",3)

Output:

"hel"

Similarly, the right command returns the last n characters.

Input:

right("hello",4)

Output:

"ello"

Previous Up Next