bdCharacter of character strings that are
substrings of the input.
substring(text, first, last) substring(text, first, last) <- value
bdCharacter of character strings.
bdNumeric giving the position within each element of
text
that is to be the first character in the respective substring,
or a character vector or
bdCharacter interpreted as regular expressions.
bdVector giving the position within each element of
text
that is to be the last character in the respective substring.
bdCharacter as long as the longest of
text,
first and
last,
(any shorter vector or
bdCharacter is replicated) containing the specified portions
of each character string.
Characters within each string are numbered from 1 to
nchar(string).
If
first is larger than the length of a string, the returned
string is
"";
last may address beyond the end of the string, but
only the characters from
first to the end of string are returned.
When a regular expression is used, the implied first and last positions
are the beginning and end of the substring matching the regular expression.
When
substring appears on the left of an assignment, the effect is to
replace the matching substrings by the
value. Where there is an empty
substring, no change is made to the original string. In particular,
replacement with a regular expression changes only those elements of
text
that match.
substring(state.name,1,8) # first 8 chars of state names
substring(state.name[1:10], 1, c(4,4,3,3,2,3,3,2,2,2))
substring("xxxxxxxxxx",1,1:10) # "x" "xx" "xxx" ...
substring("This is a test",6) # start from 6th char