The rsubstring (x, s, n) function returns a substring from the parameter x.
The second parameter (s) is the start position of the substring in the input string (x) the last parameter (n) is the stop position taken from the end of the string, the characters between the start and the stop position are returned.
In a formula using the substring and length functions rsubstring does the following:
rsubstring(x,s,n) = substring(x,s,((length (x) – s) – n))
If s is negative, an empty string will be returned.
If n is zero or negative, the substring will contain all characters from the s-th character up to the end of the string.
This function returns a value of type Text.
remainder = rsubstring(x,s,0)
This returns the remainder of a string starting at position s in the string. The 0 means that no characters from the end of the string are left out.
filename_without_extension = rsubstring(x,s,4)
This returns the input string without the last 4 characters. If the input string is a path/filename the extension is removed including the period (.).
rsubstring ("This is a counting test", 0, 3)
Result: "This is a counting t" The 0 sets the start position at the very begin of the input string, the 3 idicates that the last three characters from the end of the input string must be left out.
rsubstring ("This is a counting test", 3,0)
Result: "is is a counting test". The 3 sets the start position in the input string the empty third parameter indicates that no characters must be left out.
rsubstring ("This is a counting test", -3, 3)
Result: "", an empty string. The –3 sets an start
position outside the input string.
rsubstring ("This is a counting test", 3, 25)
Result: "", an empty string. The third parameter indicates that 25 characters from the end of the input string must be left out. Since ther are less than 25 characters in the input string from the start posiiton (parameter two: 3) in the input string the result is an empty string.