String.substring() returns the specified substring
of string. If
from equals to,
String.substring() returns an empty (length 0)
string. If from is greater than
to, this method first swaps the two
arguments before proceeding.

String.substring() can be a confusing function to
use. It is important to remember that the character at
position from is included in the substring, but that
the character at position to is not included in the
substring. One notable feature of assigning the arguments this
way is that the length of the returned substring is always
equal to to-from.

Often it is more convenient to extract a substring of a
string by specifying the start character and the desired
length of the substring. You can do this with a function
like the following: