Return a substring beginning with the rightmost character.
XSharp.Core (in XSharp.Core.dll) Version: 2.2a
Syntax View Source
cString AS STRING,
dwCount AS DWORD
) AS STRING
public static string Right(
- Type: String
The string from which to extract characters.
- Type: UInt32
The number of characters to extract.
The rightmost <dwCount> characters of <cString>. If <dwCount> is 0, Right() returns a NULL_STRING. A negative value is not allowed since a WORD cannot be negative. If <dwCount> larger than the length of the string, Right() returns <cString>.
Right() is the same as Substr(<cString>, -<wCount>). For example, Right("ABC", 1) is the same as Substr("ABC", -1). Right() is related to Left(), which extracts a substring beginning with the leftmost character in <cString>.
The Right(), Left(), and Substr() functions are often used with both the At() and RAt() functions to locate either the first and/or the last position of a substring before extracting it.
This example shows the relationship between Right() and Substr():
? Right("ABCDEF", 3) // DEF
? Substr("ABCDEF", 3) // CDEF
? Substr("ABCDEF", -3) // DEF
This example extracts a substring from the end of another string, up to the last occurrence of a comma:
LOCAL cName AS STRING
cName := "James, William"
? Right(cName, SLen(cName) - RAt(",", cName) -1) // William