Text¶
Text object. Use it to perform text manipulations.
Action Summary¶
Action | Description |
---|---|
Base64Decode | Decodes base64 string. |
Base64Encode | Converts string to base64 format. |
CharAt | Returns a new string consisting of the single UTF-16 code unit located at the specified index into the str . |
CharCodeAt | Returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index into the str . |
Concat | Append str2 to str1 . |
Contains | Perform a case-sensitive search to determine whether substr may be found within str , returning true or false as appropriate. |
EndsWith | Determines whether a str ends with the characters of substr . |
FileContains | Perform a case-sensitive search (find in file) to determine whether substr may be found within a text file represented by filePath , returning true or false as appropriate. |
FirstIndex | The first index at which a given substr can be found in the str , or -1 if it is not present. |
Format | Format given formatStr template string by expanding properties of nameValueJsonObj as {param1}, {param2} etc template params. |
IncrementDate | Increments a date/time string with a given offset. |
Join | Concatenate all of the elements in arr array (or an array-like object), separated by commas or a specified separator string. |
LastIndex | The last index at which a given substr can be found in the str , or -1 if it is not present. |
Limit | Limit str to be not more than maxLength chars. |
PadEnd | Pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. |
PadStart | Pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. |
Repeat | Returns a new string which contains the specified number of copies of str , concatenated together. |
ReplaceAll | Replace all occurences of oldValue in str with newValue . |
ReplaceFirst | Replace first occurence of oldValue in str with newValue . |
Split | Divides str into an ordered list of substrings, puts these substrings into an array, and returns the array. |
SplitAt | Get atInd th item after split. |
SplitCount | Get number of parts that will occur after splitting given str with given separator . |
StartsWith | Determines whether str begins with the characters of substr . |
Substr | Extract length characters from a str , counting from the start index. |
Substring | Text.Substring() extracts characters from indexStart up to but not including indexEnd . |
ToLowercase | Returns str value converted to lowercase. |
ToString | Convert anything to a string. |
ToUppercase | Returns the str value converted to uppercase. |
Trim | Strips leading and trailing white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string. |
TrimEnd | Strips trailing white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string. |
TrimStart | Strips leading white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string. |
Action Detail¶
Base64Decode¶
Decodes base64 string. Requires Rapise 8.1+.
Text.Base64Decode(base64EncodedData)
Parameters:
Name | Type | Description |
---|---|---|
base64EncodedData | string | Base64 encoded string. |
Base64Encode¶
Converts string to base64 format. Requires Rapise 8.1+.
Text.Base64Encode(plainText)
Parameters:
Name | Type | Description |
---|---|---|
plainText | string | Input string to encode. |
CharAt¶
Returns a new string consisting of the single UTF-16 code unit located at the specified index
into the str
.
Text.CharAt(str, index)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to extract from. |
index | number | Character position. |
Returns:
string: Char at index
.
CharCodeAt¶
Returns an integer between 0 and 65535 representing the UTF-16 code unit at the given index
into the str
.
Text.CharCodeAt(str, index)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to search in. |
index | number | Character position. |
Returns:
number: Char code at index
.
Concat¶
Append str2
to str1
.
Text.Concat(str1, str2)
Parameters:
Name | Type | Description |
---|---|---|
str1 | string | 1st part. |
str2 | string | 2nd part (may be array). |
Returns:
string: Combined string
Contains¶
Perform a case-sensitive search to determine whether substr
may be found within str
, returning true
or false
as appropriate.
Text.Contains(str, substr)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to search in. |
substr | string | Substring to find. |
Returns:
boolean: true
if substr
was found in str
.
EndsWith¶
Determines whether a str
ends with the characters of substr
.
Text.EndsWith(str, substr)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to search in. |
substr | string | Substring to find. |
Returns:
boolean: true
or false
as appropriate
FileContains¶
Perform a case-sensitive search (find in file) to determine whether substr
may be found within a text file represented by filePath
, returning true
or false
as appropriate.
Text.FileContains(filePath, substr)
Parameters:
Name | Type | Description |
---|---|---|
filePath | string | File Path. |
substr | string | Text to modify. |
Returns:
boolean: true
if substr
was found in the file.
FirstIndex¶
The first index at which a given substr
can be found in the str
, or -1 if it is not present. Search starts from fromIndex
.
Text.FirstIndex(str, substr, fromIndex)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to search in. |
substr | string | Substring to find. |
fromIndex | number | An integer representing the index at which to start the search. Defaults to 0. Optional. |
Returns:
number: Index or -1
Format¶
Format given formatStr
template string by expanding properties of nameValueJsonObj
as {param1}, {param2} etc template params.".
Text.Format("{h} {w}!", {h: "Hello", w: "World"});
Additionally you may call it with multiple string values and refer to them by index.
Text.Format("{0} {1}!", "Hello", "World");
Designed to be called from JavaScript. If you need to call it from RVL
then consider using RVL.FormatString
instead.
Text.Format(formatStr, nameValueJsonObj)
Parameters:
Name | Type | Description |
---|---|---|
formatStr | string | Format with template placeholders {a}, {value}, {x} etc. |
nameValueJsonObj | object | JSON-formatted object, with properties used as input parameter names. |
Returns:
string: Formatted string
IncrementDate¶
Increments a date/time string with a given offset. Requires Rapise 8.1+.
-
Parses date using given format specifier. Formatting is described here.
Example:
yyyy-MM-dd HH:mm
-
Adds/Subtracts specified number of years, months, days, hours, minutes. The number may be negative or positive, i.e. months=2 adds 2 months, months=-3 goes 3 months back, months=0 leaves months intact.
- Formats the date back and returns.
Text.IncrementDate(dstr, fmt, years, months, days, hours, minutes)
Parameters:
Name | Type | Description |
---|---|---|
dstr | string | Date/time string. If not set then current date/time is used. |
fmt | string | Date/time format. |
years | number | Year increment/decrement. |
months | number | Month increment/decrement. |
days | number | Day increment/decrement. |
hours | number | Hour increment/decrement. |
minutes | number | Minute increment/decrement. |
Join¶
Concatenate all of the elements in arr
array (or an array-like object), separated by commas or a specified separator
string. If the array has only one item, then that item will be returned without using the separator.
Text.Join(arr, separator)
Parameters:
Name | Type | Description |
---|---|---|
arr | array | Input array. |
separator | string | Join separator (default - ',') Optional. |
Returns:
string: A string with all array elements joined. If arr.length is 0, the empty string is returned.
LastIndex¶
The last index at which a given substr
can be found in the str
, or -1 if it is not present. Search backwards from fromIndex
.
Text.LastIndex(str, substr, fromIndex)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to search in. |
substr | string | Substring to find. |
fromIndex | number | An integer representing the index at which to start the search. Defaults to 0. Optional. |
Returns:
number: Index or -1
Limit¶
Limit str
to be not more than maxLength
chars. If ellipsis
is specified, it is appended to the string.
Text.Limit(str, maxLength, ellipsis)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to limit. |
maxLength | number | The maximum allowed length of the resulting string. |
ellipsis | string | The padding text to append to the end if the string was actually shortened. Optional. |
Returns:
string: Whole or shortened string.
PadEnd¶
Pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied to the end of the str
.
Text.PadEnd(str, targetLength, padString)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to pad. |
targetLength | number | The length of the resulting string once the current str has been padded. If the value is less than str.length, then str is returned as-is. |
padString | string | The string to pad the current str with. |
Returns:
string: A String of the specified targetLength
with padString
applied from the start.
PadStart¶
Pads the current string with another string (multiple times, if needed) until the resulting string reaches the given length. The padding is applied from the start of the str
.
Text.PadStart(str, targetLength, padString)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to pad. |
targetLength | number | The length of the resulting string once the current str has been padded. If the value is less than str.length, then str is returned as-is. |
padString | string | The string to pad the current str with. |
Returns:
string: A String of the specified targetLength
with padString
applied from the start.
Repeat¶
Returns a new string which contains the specified number of copies of str
, concatenated together.
Text.Repeat(str, count)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to repeat. |
count | number | Number of times to repeat. |
Returns:
string: string containing the specified number of copies of the given string.
ReplaceAll¶
Replace all occurences of oldValue
in str
with newValue
.
Text.ReplaceAll(str, oldValue, newValue)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to modify. |
oldValue | string | Substring to find. |
newValue | string | Replacement value. |
Returns:
string: Text after replace.
ReplaceFirst¶
Replace first occurence of oldValue
in str
with newValue
.
Text.ReplaceFirst(str, oldValue, newValue)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to modify. |
oldValue | string | Substring to find. |
newValue | string | Replacement value. |
Returns:
string: Text after replace.
Split¶
Divides str
into an ordered list of substrings, puts these substrings into an array, and returns the array. The division is done by searching for a separator
.
Text.Split(str, separator)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to split. |
separator | string | Split separator |
Returns:
array: Array of strings
SplitAt¶
Get atInd
th item after split. If atInd
<0 or atInd
is more than split array size, null
is returned.
Text.SplitAt(str, separator, atInd)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to split. |
separator | string | Split separator |
atInd | number | 0-based index of item |
Returns:
string: Item string or null, if index is out of scope.
SplitCount¶
Get number of parts that will occur after splitting given str
with given separator
.
Text.SplitCount(str, separator)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to split. |
separator | string | Split separator |
Returns:
number: Number of split parts
StartsWith¶
Determines whether str
begins with the characters of substr
.
Text.StartsWith(str, substr)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to search in. |
substr | string | Substring to find. |
Returns:
boolean: true
or false
as appropriate
Substr¶
Extract length
characters from a str
, counting from the start
index.
- If
start
is a non-negative number, the index starts counting from the start of the string. Its value is capped atstr.length - 1
. - If
start
is a negative number, the index starts counting from the end of the string. Its value is capped at-str.length
. - If
length
is omitted,Text.Substr()
extracts characters to the end of the string. - If
length
isundefined
,Text.Substr()
extracts characters to the end of the string. - If
length
is a negative number, it is treated as 0. - For both start and length,
NaN
is treated as 0.
Text.Substr(str, start, length)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to extract from. |
start | number | where to start the substring. |
length | number | how many characters to return. Optional. |
Returns:
string: Substring
Substring¶
Text.Substring() extracts characters from indexStart
up to but not including indexEnd
. In particular:
- If
indexEnd
is omitted,Text.Substring()
extracts characters to the end of the string. - If
indexStart
is equal to indexEnd,Text.Substring()
returns an empty string. - If
indexStart
is greater thanindexEnd
, then the effect ofText.Substring()
is as if the two arguments were swapped;
Any argument value that is less than 0 or greater than str.length
is treated as if it were 0 and str.length
, respectively.
Text.Substring(str, indexStart, indexEnd)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to extract from. |
indexStart | number | The index of the first character to include in the returned substring. |
indexEnd | number | The index of the first character to exclude from the returned substring. Optional. |
Returns:
string: Substring
ToLowercase¶
Returns str
value converted to lowercase.
Text.ToLowercase(str)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to process. |
Returns:
string: Lowercase value.
ToString¶
Convert anything to a string.
Text.ToString(anyObj)
Parameters:
Name | Type | Description |
---|---|---|
anyObj | object | Object of any type |
Returns:
string: string representation of the object
ToUppercase¶
Returns the str
value converted to uppercase.
Text.ToUppercase(str)
Parameters:
Name | Type | Description |
---|---|---|
str | string | Text to process. |
Returns:
string: Uppercase value.
Trim¶
Strips leading and trailing white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string. Whitespace characters are [ \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff].
Text.Trim(str, global, trimChars)
Parameters:
Name | Type | Description |
---|---|---|
str | string | String to trim. |
global | boolean | If 'true' then global trim is performed (whitespaces in the middle are substituted with a single space). If 'false' only ends are trimmed. Optional, Default: "false". |
trimChars | string | String with each char to be subject for trim. Optional. |
Returns:
string: Trimmed string.
TrimEnd¶
Strips trailing white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string. Whitespace characters are [ \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff].
Text.TrimEnd(str, trimChars)
Parameters:
Name | Type | Description |
---|---|---|
str | string | String to trim. |
trimChars | string | String with each char to be subject for trim. Optional. |
Returns:
string: Trimmed string.
TrimStart¶
Strips leading white-space from a string, replaces sequences of whitespace characters by a single space, and returns the resulting string. Whitespace characters are [ \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff].
Text.TrimStart(str, trimChars)
Parameters:
Name | Type | Description |
---|---|---|
str | string | String to trim. |
trimChars | string | String with each char to be subject for trim. Optional. |
Returns:
string: Trimmed string.