6.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 6.15.3, Section 6.37.1,
Section 6.38.2, Section 6.40.6, Section 6.55.4 and
Section 6.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"