CharToString(code) : String?
Converts UTF32 character code to string.
CharToString Parameters
code : int
CharToString Examples
var ok = CharToString(65) == 'A';
Diff(str1, str2, wordMode = false) : []
Finds differences between two strings.
Returns array of change objects { Operation, Text }.
Operation can be ‘Equal’, ‘Delete’ or ‘Insert’.
Diff Parameters
str1 : String?
str2 : String?
wordMode : Boolean = false
Diff Examples
var diff = Diff('Test Data', 'Test Data2');
var ok = diff.(2).Operation == 'Insert' and diff.(2).Text == '2';
Ellipsis(str, length) : String?
Truncates string to the specified length and inserts ellipsis symbol if truncated.
Ellipsis Parameters
str : String?
length : Integer
Ellipsis Examples
var ok = Ellipsis('Test Data', 5) == 'Test…';
var ok = Ellipsis('Test Data', 15) == 'Test Data';
EndsWith(str, end, ignoreCase = false) : Boolean
Determines if a string ends with specified substring.
EndsWith Parameters
str : String?
end : String?
ignoreCase : Boolean = false
EndsWith Examples
var ok = 'Test Data'.EndsWith('Data');
var ok = 'Test Data'.EndsWith('data', true);
GenerateUid() : String?
Generates a unique ID string.
IdentifierToTitle(name) : String?
Converts identifier name to title text.
IdentifierToTitle Parameters
name : String?
IdentifierToTitle Examples
var ok = IdentifierToTitle('SomeVariable') == 'Some Variable';
var ok = IdentifierToTitle('SomeVariable_and_more') == 'Some Variable And More';
Match(source, pattern, flags?)
Searches the source string for the regex pattern.
Returns boolean result or array, depending on flags.
Match Parameters
source : String?
pattern : String?
flags? : String
May consist of the following symbols:
Match Examples
var ok = 'Some input text'.Match('ex');
var ok = 'Some input text'.Match('^.*put.*$');
var groups = 'some input text'.Match('([a-z]{4}).*([a-z]{4})', 'G');
var ok = groups.(2).Value == 'some' and groups.(3).Value == 'text';
var matches = 'some input text'.Match('([a-z])([a-z]{3})(?![a-z])', 'A');
var ok = matches.(1).(1).Value == 'some' and matches.(1).(2).Value == 's' and matches.(1).(3).Value == 'ome'
and matches.(2).(1).Value == 'nput' and matches.(2).(2).Value == 'n' and matches.(2).(3).Value == 'put'
and matches.(3).(1).Value == 'text' and matches.(3).(2).Value == 't' and matches.(3).(3).Value == 'ext';
MinifyCode(code, codeType, sourceName?, failOnError = false) : String?
Alias: Minify
Minifes code (js/json/css/html).
MinifyCode Parameters
code : String?
codeType : String
‘js’ – javascript, ‘json’ – JSON, ‘css’ – CSS, ‘html’ – HTML.
sourceName? : String?
Source name to use if error occurs during minification.
failOnError : Boolean = false
If false, then ignores errors and returns original code.
Pluralize(word) : String?
Makes plural form of the word.
Pluralize Parameters
word : String?
Pluralize Examples
var ok = Pluralize('Person') == 'People';
var ok = Pluralize('Man') == 'Men';
RegexEscape(str) : String?
Replaces all characters that are special in regex syntax with their escape codes.
RegexEscape Parameters
str : String?
RegexEscape Examples
var ok = RegexEscape('.*?') == '\\.\\*\\?';
Replace(text, search, replace, isRegex = true) : String?
Finds and replaces specified pattern in specified text (using regex or exact match).
Replace Parameters
text : String?
search : String?
replace : String?
Can be string replace pattern or function (v, groups) => replace.
isRegex : Boolean = true
or string option ‘i’
Replace Examples
var ok = 'text'.Replace('(.)', '$1$1') == 'tteexxtt';
Split(text, pattern, anyChar = false, options?) : String[]
Splits string to an array of strings by regex pattern or by separator characters.
Split Parameters
text : String?
pattern : String?
anyChar : Boolean = false
True to split by any character of the pattern (no regex split).
options? : String?
options, i: IgnoreCase (regex only), T: trim
Split Examples
var ok = 'some input text'.Split(' ') == ['some', 'input', 'text'];
var ok = 'aa-bb+cc*dd/ee'.Split('+-*/', true) == ['aa', 'bb', 'cc', 'dd', 'ee'];
StartsWith(str, start, ignoreCase = false) : Boolean
Determines if a string starts with specified substring.
StartsWith Parameters
str : String?
start : String?
ignoreCase : Boolean = false
StartsWith Examples
var ok = 'Test Data'.StartsWith('Test');
var ok = 'Test Data'.StartsWith('test', true);
StringJoin(array, separator?, selectorOrTrimFlag?) : String?
Concatenates all the items of array, using the specified separator between each item.
StringJoin Parameters
array : []?
separator? : String?
selectorOrTrimFlag? : ?
Can be function ((item, index) => value) or boolean trim flag.
True to trim starting and ending whitespace characters from each item and to exclude all empty items from joining.
StringJoin Examples
var ok = ['a', 'b', ' ', 'c'].StringJoin(', ') == 'a, b, , c';
var ok = ['a', 'b', ' ', 'c'].StringJoin(', ', true) == 'a, b, c';
var ok = [{A='a'}, {A='b'}, {A='c'}].StringJoin(', ', o => o.A) == 'a, b, c';
Substitute(template, scope?, templateName?) : String?
Alias: $
Substitutes template (e.g. replaces all $(var?.prop? -> format) occurences with corresponding values).
Substitute Parameters
template : String?
scope? : ?
If missing, then current evaluation scope is used.
templateName? : String?
Optional template name for error messages.
Substitute Examples
var ok = Substitute('Hello $(Name)! Be my $(Role).', { Name='John', Role='Guest' }) == 'Hello John! Be my Guest.';
Substring(str, start, count?) : String?
Returns substring of a string.
Substring Parameters
str : String?
start : Integer
If negative, then counts from the length of the string (e.g. -1 = last character).
count? : Integer
If missing, then string length is used by default.
Substring Examples
var ok = 'Some text'.Substring(6) == 'text';
var ok = 'Some text'.Substring(6, 2) == 'te';
Surround(str, prefix, suffix?) : String?
Surrounds a string with prefix and suffix.
Surround Parameters
str : String?
prefix : String?
suffix? : String?
If missing, then prefix is used as suffix.
Surround Examples
var ok = 'text'.Surround('(', ')') == '(text)';
var ok = 'text'.Surround('-') == '-text-';
Template(body, name?, eval?) : Template
Returns template object that can be substituted in a scope.
Template Parameters
body : String?
Template body text, may contain variables.
name? : String?
Template name (mostly used in error messages).
eval? : Function?
Evaluator function ((scope, name) => value) that returns either prop value by name or missing to indicate error.
Template Examples
var tpl = Template('Hello $(Name)! Be my $(Role).', 'Greeting');
var ok = tpl.Substitute({ Name='John', Role='Guest' }) == 'Hello John! Be my Guest.';
TitleToIdentifier(title) : String?
Converts title text to identifier name.
TitleToIdentifier Parameters
title : String?
TitleToIdentifier Examples
var ok = TitleToIdentifier('Some Variable') == 'SomeVariable';
var ok = TitleToIdentifier('Some variable and more') == 'SomeVariableAndMore';
ToLower(str) : String?
Converts string to lowercase.
ToLower Parameters
str : String?
ToLower Examples
var ok = ToLower('Some Text') == 'some text';
ToString(value, format?) : String?
Converts value to string.
ToString Parameters
value : ?
format? : String?
The following format is supported:
?@ utc (minLength,maxLength,fillChar) default|negative|positive [keyformat][subformat]
The symbol ‘?’ activates ‘skip-null’ mode: if set, then no formatting and wrapping is applied for null value and empty string is generated.
The symbol ‘@’ activates ‘skip-keys’ mode: if set, then only dictionary values are formatted, keys are ignored.
The modifier ‘utc’ forces formatting time values in UTC instead of current users’s time zone.
minLength – minimum length of the formatted value (without prefix and suffix).
If the length of the formatted value is less than Abs(minLength) then it is filled with fillChar.
The fillChar is appended if minLength is positive and prepended if negative.
maxLength – maximum length of the formatted value (without prefix and suffix).
If zero then no maximum length.
If the length of the formatted value is greater than Abs(maxLength) then it is truncated:
– from the end if maxLength is positive;
– from the beginning if maxLength is negative.
fillChar – the symbol to fill gaps in the case when the length of the formatted value is less than Abs(minLength).
default|negative|positive – specifies value format and wrapping.
Default format is required, negative and positive are optional (separated by ‘|’).
If all three formats are specified, then each format is used depending on value: negative format is used for negative values,
positive format is used for positive values and default format is used for neutral values. If any format is omitted, then default one is used.
Negative format is applied to negative numbers, boolean false, dates from past, null, empty strings, empty arrays, etc.
Positive format is applied to positive numbers, boolean true, dates from future, non-empty strings, non-empty arrays, etc.
Value format looks like ‘prefix/format/suffix’ where preffix and suffix are textual parts to wrap formatted value,
while format depends on value type and specifies formatting of the value (e.g. ‘0.00#’).
Value format can be specified in special html tag form, for example ‘<li>’ expands to ‘<li>//</li>’ (prefix and suffix tags with default value format).
keyformat – is a subformat used for dictionary keys, supports all the modifiers including nested keyformat and subformat.
If not set, then subformat is used.
subformat – is a subformat used for array items and dictionary values, supports all the modifiers including nested keyformat and subformat.
If not set, then current format is used for nested items as well.
ToString Examples
var ok = ToString('test', '(6,,_)') == 'test__';
var ok = ToString('test', '(-6,,_)') == '__test';
var ok = ToString('test', '(,3)') == 'tes';
var ok = ToString('test', '(,-3)') == 'est';
var ok = ToString(5, '000|(000)') == '005';
var ok = ToString(-5, '000|(000)') == '(005)';
var ok = ToString(5, 'N\\/A|number: -/0|number: /0') == 'number: 5';
var ok = ToString(-5, 'N\\/A|number: -/0|number: /0') == 'number: -5';
var ok = ToString(0, 'N\\/A|number: -/0|number: /0') == 'N/A';
var ok = ToString([1, 2], '\\(//)') == '(1)\n(2)';
var ok = ToString([1, 2], '\\(/, /)[0]') == '(1, 2)';
ToUpper(str) : String?
Converts string to uppercase.
ToUpper Parameters
str : String?
ToUpper Examples
var ok = ToUpper('Some Text') == 'SOME TEXT';
Trim(str, trimChars?) : String?
Removes all leading and trailing occurrences of a specified set of characters.
Trim Parameters
str : String?
trimChars? : String
Omit to trim whitespace characters.
Trim Examples
var ok = Trim(' test\n ') == 'test';
var ok = Trim('-- test --', ' -') == 'test';
TrimEnd(str, trimChars?) : String?
Removes all trailing occurrences of a specified set of characters.
TrimEnd Parameters
str : String?
trimChars? : String
Omit to trim whitespace characters.
TrimEnd Examples
var ok = TrimEnd(' test\n ') == ' test';
var ok = TrimEnd('-- test --', ' -') == '-- test';
TrimStart(str, trimChars?) : String?
Removes all leading occurrences of a specified set of characters.
TrimStart Parameters
str : String?
trimChars? : String
Omit to trim whitespace characters.
TrimStart Examples
var ok = TrimStart(' test\n ') == 'test\n ';
var ok = TrimStart('-- test --', ' -') == 'test --';