Text_2 class
Operations for working with strings that contain text.
Remarks
The utilities provided by this class are intended to be simple, small, and very broadly applicable.
Methods
format(s, values) | Format a string by substituting parameters. |
replace |
Returns the input string, with all instances of |
Method Details
format(s, values)
Format a string by substituting parameters.
static format(s: string, ...values: unknown[]): string;
Parameters
- s
-
string
- values
-
unknown[]
Returns
string
Remarks
This function replaces template parameters such as "{0}"
or "{1}"
with the corresponding argument. If the value is null or undefined, it will be replaced by the word "null"
or "undefined"
. The format string s must not be null or undefined.
Usage example:
Text.format("hello {0}!", "world")
will return "hello world!"
replaceAll(input, searchValue, replaceValue)
Returns the input string, with all instances of searchValue
replaced by replaceValue
.
static replaceAll(input: string, searchValue: string, replaceValue: string): string;
Parameters
- input
-
string
The string to be modified
- searchValue
-
string
The value to search for
- replaceValue
-
string
The replacement text
Returns
string
Remarks
Note that JavaScript's string.replace()
only replaces the first match, unless a global RegExp is provided.