@LeftBack (JavaScript)
Returns the leftmost characters of a string minus the number of characters specified, or up to and excluding the last occurrence of a substring.
Defined in
@Functions (JavaScript)Syntax
@LeftBack(value:string, n:int)
: string@LeftBack(value:string, subString:string)
: string
| Parameter | Description |
|---|---|
value |
The string to check. |
n |
Number of characters. The function returns the leftmost characters minus the number of characters specified. A real number is truncated to a fraction. |
subString |
A substring. The function returns the leftmost characters up to and excluding the last occurrence of the substring. |
| Return value | Description |
|---|---|
string |
The leftmost characters. |
Usage
This function returns:- An empty string if
nexceeds the length of the string. - The entire string if
nis negative. - The entire string if
nis 0. - An empty string if
subStringis not found.
Examples
(1) This example gets the leftmost 5 characters, the rightmost 6 characters, and the characters less the first 6 and the last 7.function p(stuff) {
print("<<<" + stuff + ">>>");
}
var lineitem = "Q5212 peaches and cream 001.99";
var code = @Left(lineitem, 5);
var price = @Right(lineitem, 6);
var description = @LeftBack(@RightBack(lineitem, 6), 7);
p("Code = " + code); // Q5212
p("Price = " + price); // 001.99
p("Description = " + description); // peaches and cream(2) This example gets the leftmost characters up to the first space, the rightmost characters back to the last space, and the characters between the first and last spaces.
function p(stuff) {
print("<<<" + stuff + ">>>");
}
var lineitem = "Q5212 peaches and cream 001.99";
var code = @Left(lineitem, " ");
var price = @RightBack(lineitem, " ");
var description = @LeftBack(@Right(lineitem, " "), " ");
p("Code = " + code); // Q5212
p("Price = " + price); // 001.99
p("Description = " + description); // peaches and cream