Original Author Paul Laughton, 2011
Page 65
De Re BASIC!
Otherwise, the absolute value of the count specifies the length of the returned substring:
If the count is greater than 0, begin at <start_nexp> and count characters to the right.
That is, return the substring that begins at the start position.
If the start position is greater than the length of the string, return an empty string ("").
If the count is less than 0, begin at <start_nexp> and count characters to the left.
That is, return the substring that ends at the start position.
If the start position is greater than the length of the string, it is set to the end of the string.
If the count is 0, return an empty string ("").
a$ = MID$("dinner", 2, 3)
% a$ is "inn"
a$ = MID$("dinner", 4, -3)
% a$ is "inn"
a$ = MID$("dinner", 3, 0)
% a$ is ""
RIGHT$(<sexp>, <count_nexp>)
Return the right-most characters of the string <sexp>. The number of characters to return is set by the
count parameter, <count_nexp>.
If the count is greater than 0, return <count_nexp> characters, counting from the right.
If the count is less than 0, return all but <count_nexp> characters. The number to return is the
string length reduced by <count_nexp>: RIGHT$(a$, -2) is the same as RIGHT$(a$, LEN(a$) - 2).
If the count is 0, return an empty string ("").
If the count is greater than the length of the string, return the entire string.
REPLACE$(<sexp>, <argument_sexp>, <replace_sexp>)
Returns <sexp> with all instances of <argument_sexp> replaced with <replace_sexp>.
TRIM$(<sexp>{, <test_sexp>})
Returns <sexp> with leading and trailing occurrences of <test_sexp> removed.
The expression to trim off, <test_sexp>, is optional. If omitted, all leading and trailing whitespace is
removed. That is, the default <test_sexp> is the regular expression "\s+", which means "all whitespace".
To use this regular expression in a BASIC! string, you must write it "\\s+" (escape the backslash).
As with the WORD$() function and the SPLIT command, the <test_exp> is a regular expression. See Split
for a note about Regular Expressions.
LTRIM$(<sexp>{, <test_sexp>})
RTRIM$(<sexp>{, <test_sexp>})
Exactly like TRIM$(), except that LTRIM$() trims only the left end of the source string <sexp>, while
RTRIM$() trims only the right end.