Return a substring beginning with the rightmost character.
XSharp.Core (in XSharp.Core.dll) Version: 2.6
Syntax Request Example
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():
1? Right("ABCDEF", 3)
2? Substr("ABCDEF", 3)
3? Substr("ABCDEF", -3)
This example extracts a substring from the end of another string, up to the last occurrence of a comma:
1LOCAL cName AS STRING
2cName := "James, William"
3? Right(cName, SLen(cName) - RAt(",", cName) -1)