The substring method returns a String object that contains the substring obtained from the original object.
The substring method uses a smaller value of start and end as the starting point of the substring. For example, strvar. substring (0, 3) and strvar. substring (3, 0) return the same substring.
The substring method uses a smaller value of start and end as the starting point of the substring. For example, strvar. substring (0, 3) and strvar. substring (3, 0) return the same substring.
The only exception is the processing of negative parameters. If the first parameter is smaller than 0, it is processed as 0. If the second parameter is a negative value, it is set to the value of the first parameter.
The following example demonstrates the usage of the substring method:
Function substringdemo ()
{
VaR S, SS;
VaR S = "The quick brown fox jumped over the lazy yellow dog .";
Ss = S. substring (16, 19 );
Return (SS );
}
STR = abcdefghijklmnopqrstuvwxyz
Str. substr () returns E
Str. substr (4): efghijklmnopqrstuvwxyz
Str. substr () The result is
Str. substring () returns EFG
Str. substring () returns EFG
Str. substring (-, 4) returns ABCD