5.3.4 The left and right parts of a string: left right
The left and right commands can find the left and right
parts of a string. (See Section 5.15.3, Section 5.37.1,
Section 5.38.2, Section 5.40.6, Section 5.55.4 and
Section 5.55.5 for other uses of left and right.)
- left takes two arguments:
- str, a string.
- n, a non-negative integer.
- left(str,n) returns the first n
characters of the string str.
Example
Input:
left("hello",3)
Output:
"hel"
- right takes two arguments:
- str, a string.
- n, a non-negative integer.
- right(str,n) returns the last n
characters of the string str.
Example
Input:
right("hello",4)
Output:
"ello"