Functions from R - U
rand
Return a random integer from a specified range, which is inclusive only at the starting end.
rand(, )
Parameter | Required | Type | Description |
---|---|---|---|
<minValue> | Yes | integer | The lowest integer in the range |
<maxValue> | Yes | integer | The integer that follows the highest integer in the range that the function can return |
Return value | Type | Description |
---|---|---|
<random-result> | integer | The random integer returned from the specified range |
Example
This example gets a random integer from the specified range, excluding the maximum value:
rand(1, 5)
And returns 1, 2, 3, or 4 as the result.
range
Return an integer array that starts from a specified integer.
range(, )
Parameter | Required | Type | Description |
---|---|---|---|
<startIndex> | Yes | integer | An integer value that starts the array as the first item |
<count> | Yes | integer | The number of integers in the array |
Return value | Type | Description |
---|---|---|
<range-result> | integer | The array with integers starting from the specified index |
Example
This example creates an integer array that starts from the specified index 1 and has the specified number of integers as 4:
range(1, 4)
And returns the result [1, 2, 3, 4].
removeProperty
Remove a property from an object and return the updated object.
removeProperty(, '')
Parameter | Required | Type | Description |
---|---|---|---|
<object> | Yes | object | The JSON object in which you want to remove a property |
<property> | Yes | string | The name of the property to remove |
Return value | Type | Description |
---|---|---|
<updated-object> | object | The updated JSON object without the specified property |
Example
This example removes the accountLocation
property from a customerProfile
object, which is converted to JSON with the json() function, and returns the updated object:
removeProperty(json('customerProfile'), 'accountLocation')
replace
Replace a substring with the specified string, and return the result string. This function is case-sensitive.
replace('', '', '')
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The string that has the substring to replace |
<oldText> | Yes | string | The substring to replace |
<newText> | Yes | string | The replacement string |
Return value | Type | Description |
---|---|---|
<updated-text> | string | The updated string after replacing the substring. If the substring isn't found, the function returns the original string. |
Example 1
This example finds the substring old in the old string and replaces old with new:
replace('the old string', 'old', 'new')
The result is the string the new string.
Example 2
When dealing with escape characters, the expression engine handles the unescape for you. This function replaces strings with escape characters.
replace('hello"', '"', '\n')
replace('hello\n', '\n', '\\')
@"replace('hello\', '\', '\\')"
@"replace('hello\n', '\n', '\\')"
And returns the following results respectively:
- hello\n
- hello\\
- @"hello\\"
- @"hello\\"
replaceIgnoreCase
Replace a substring with the specified string, and return the result string. This function is case-insensitive.
replaceIgnoreCase('', '', '')
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The string that has the substring to replace |
<oldText> | Yes | string | The substring to replace |
<newText> | Yes | string | The replacement string |
Return value | Type | Description |
---|---|---|
<updated-text> | string | The updated string after replacing the substring. If the substring isn't found, return the original string. |
Example
This example finds the substring old in the string the old string and replaces old with new:
replace('the old string', 'old', 'new')
And returns the result the new string.
resolve
Return string of a given TimexProperty or Timex expression if it refers to a valid time. Valid time contains hours, minutes, and seconds.
resolve('<timestamp')
Parameter | Required | Type | Description |
---|---|---|---|
<timestamp> | Yes | string | The string that contains the timestamp. |
Return value | Type | Description |
---|---|---|
<return> | string | A string of the evaluated TimexProperty or Timex expression. |
Examples
These examples show if the given strings refer to valid time:
resolve(T14)
resolve(2020-12-20)
resolve(2020-12-20T14:20)
And returns the following results respectively:
- 14:00:00
- 2020-12-20
- 2020-12-20 14:20:00
reverse
Reverse the order of the elements in a string or array.
reverse()
Parameter | Required | Type | Description |
---|---|---|---|
<value> | Yes | string or array | The string to array to reverse. |
Return value | Type | Description |
---|---|---|
<return> | string or array | The reversed elements of a string or array. |
Examples
These examples reverse the elements of a string or array:
reverse(hello)
reverse(concat(hello,world))
And return the following values respectively:
-The string olleh. -The string dlrowolleh.
round
Round a value to the nearest integer or to the specified number of fractional digits.
round('', '')
Parameter | Required | Type | Description |
---|---|---|---|
<number> | Yes | number | An input number |
<precision-digits> | No | integer | A specified number of fractional digits. The default is 0. |
Return value | Type | Description |
---|---|---|
<return-value> | number | The return value of the input rounded at a specified number of fractional digits. |
Example 1
This example rounds the number 10.333:
round(10.333)
And returns the number 10.
Example 2
This example rounds the number 10.3313 to 2 fractional digits:
round(10.3313, 2)
And returns the number 10.33.
select
Operate on each element and return the new collection of transformed elements.
select([<collection/instance>], , )
Parameter | Required | Type | Description |
---|---|---|---|
<collection/instance> | Yes | array | The collection with the items |
<iteratorName> | Yes | iterator name | The key item |
<function> | Yes | expression | Th function that can contains iteratorName |
Return value | Type | Description |
---|---|---|
<new-collection> | array | The new collection in which each element has been evaluated with the function. |
Example 1
This example generates a new collection:
select(createArray(0, 1, 2, 3), x, x + 1)
And returns the result [1, 2, 3, 4].
Example 2
These examples generate a new collection:
select(json("{'name': 'jack', 'age': '15'}"), x, concat(x.key, ':', x.value))
select(json("{'name': 'jack', 'age': '15'}"), x=> concat(x.key, ':', x.value))
And return the result ['name:jack', 'age:15']. Note that the second expression is a lambda expression, which some find more readable.
sentenceCase
Capitalize the first letter of the first word in a string in an optional locale format.
sentenceCase('', ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The original string |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
result string | string | Returns the sentence case result |
Example 1
These examples capitalize the first letter in a string:
sentenceCase('a')
sentenceCase('abc def')
sentenceCase('aBC dEF')
And return the following results respectively:
- A
- Abc def
- Abc def
Example 2
These examples capitalizes the first letter in a string in the specified locale format:
sentenceCase('a', 'fr-FR')
sentenceCase('abc', 'en-US')
sentenceCase('aBC', 'fr-FR')
And return the following results respectively:
- A
- Abc
- Abc
setPathToValue
Retrieve the value of the specified property from the JSON object.
setPathToValue(, )
Parameter | Required | Type | Description |
---|---|---|---|
<Path> | Yes | object | The path which you want to set |
<value> | Yes | object | The value you want to set to the path |
Return value | Type | Description |
---|---|---|
value | object | The value be set |
Example 1
The example below sets the value 1 to the path:
setPathToValue(path.x, 1)
And returns the result 1. path.x
is set to 1.
Example 2
This example below sets the value:
setPathToValue(path.array[0], 7) + path.array[0]
And returns the result 14.
setProperty
Set the value of an object's property and return the updated object. To add a new property, use this function or the addProperty() function.
setProperty(, '', )
Parameter | Required | Type | Description |
---|---|---|---|
<object> | Yes | object | The JSON object in which you want to set a property |
<property> | Yes | string | The name of the property to set |
<value> | Yes | any | The value to set for the specified property |
Return value | Type | Description |
---|---|---|
<updated-object> | object | The updated JSON object whose property you set |
Example
This example sets the accountNumber
property on a customerProfile
object, which is converted to JSON with the json() function. The function assigns a value generated by the newGuid() function, and returns the updated JSON object:
setProperty(json('customerProfile'), 'accountNumber', newGuid())
skip
Remove items from the front of a collection, and return all the other items.
skip([], )
Parameter | Required | Type | Description |
---|---|---|---|
<collection> | Yes | array | The collection whose items you want to remove |
<count> | Yes | integer | A positive integer for the number of items to remove at the front |
Return value | Type | Description |
---|---|---|
<updatedCollection> | array | The updated collection after removing the specified items |
Example
This example removes one item, the number 1, from the front of the specified array:
skip(createArray(0, 1, 2, 3), 1)
And returns an array with the remaining items: [1,2,3].
sortBy
Sort elements in the collection in ascending order and return the sorted collection.
sortBy([], '')
Parameter | Required | Type | Description |
---|---|---|---|
<collection> | Yes | string or array | The collection to sort |
<property> | No | string | Sort by this specific property of the object element in the collection if set |
Return value | Type | Description |
---|---|---|
<new-collection> | array | The new collection whose elements have been sorted |
Example 1
This example generates sorts the following collection:
sortBy(createArray(1, 2, 0, 3))
And return the result [0, 1, 2, 3].
Example 2
Suppose you have the following collection:
{
'nestedItems': [
{'x': 2},
{'x': 1},
{'x': 3}
]
}
This example generates a new sorted collection based on the x object property
sortBy(nestedItems, 'x')
And returns the result:
{
'nestedItems': [
{'x': 1},
{'x': 2},
{'x': 3}
]
}
sortByDescending
Sort elements in the collection in descending order, and return the sorted collection.
sortBy([], '')
Parameter | Required | Type | Description |
---|---|---|---|
<collection> | Yes | string or array | The collection to sort |
<property> | No | string | Sort by this specific property of the object element in the collection if set |
Return value | Type | Description |
---|---|---|
<new-collection> | array | The new collection whose elements have been sorted |
Example 1
This example generates a new sorted collection:
sortByDescending(createArray(1, 2, 0, 3))
And returns the result [3, 2, 1, 0].
Example 2
Suppose you have the following collection:
{
'nestedItems': [
{'x': 2},
{'x': 1},
{'x': 3}
]
}
This example generates a new sorted collection based on the x object property:
sortByDescending(nestedItems, 'x')
And returns this result:
{
'nestedItems': [
{'x': 3},
{'x': 2},
{'x': 1}
]
}
split
Return an array that contains substrings, separated by commas, based on the specified delimiter character in the original string.
split('', ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The string to separate into substrings based on the specified delimiter in the original string. If null, it will be empty. |
<delimiter> | No | string | The character in the original string to use as the delimiter. If null or not provided, the default will be an empty string. |
Return Value | Type | Description |
---|---|---|
[<substring1>,<substring2>,...] | array | An array that contains substrings from the original string, separated by commas. |
Examples
These examples create an array with substrings from the specified string based on the specified delimiter character:
split('abc', '**')
split('hello', '')
split('', 'e')
split('', '')
split('hello')
And returns the following arrays as the result respectively:
- ["a", "b", "c"]
- ["h", "e", "l", "l", "o"]
- [""], [ ]
- ["h", "e", "l", "l", "o"]
sqrt
Return the square root of a specified number.
sqrt()
Parameter | Required | Type | Description |
---|---|---|---|
<number> | Yes | number | Number to get square root of of |
Return value | Type | Description |
---|---|---|
<result> | number | The result from computing the square root. |
Examples
These examples compute the square root of specified numbers:
sqrt(9)
sqrt(0)
And return the following results respectively:
- 3
- 0
startOfDay
Return the start of the day for a timestamp in an optional locale format.
startOfDay('', ''?, ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<timestamp> | Yes | string | The string that contains the timestamp |
<format> | No | string | A custom format pattern. The default format for the timestamp is UTC ISO format (YYYY-MM-DDTHH:mm:ss.fffZ), compliant with ISO 8601. |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
<updated-timestamp> | string | The specified timestamp starting at the zero-hour mark for the day |
Example 1
This example finds the start of the day:
startOfDay('2018-03-15T13:30:30.000Z')
And returns the result 2018-03-15T00:00:00.000Z.
Example 2
This example finds the start of the day with the locale fr-FR:
startOfDay('2018-03-15T13:30:30.000Z', '', 'fr-FR')
And returns the result 15/03/2018 00:00:00.
startOfHour
Return the start of the hour for a timestamp in an optional locale format.
startOfHour('', ''?, ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<timestamp> | Yes | string | The string that contains the timestamp |
<format> | No | string | A custom format pattern. Default is UTC ISO format (YYYY-MM-DDTHH:mm:ss.fffZ), compliant with ISO 8601. |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
<updated-timestamp> | string | The specified timestamp starting at the zero-minute mark for the day |
Example 1
This example finds the start of the hour:
startOfHour('2018-03-15T13:30:30.000Z')
And returns the result 2018-03-15T13:00:00.000Z.
Example 2
This example finds the start of the hour with the locale fr-FR:
startOfHour('2018-03-15T13:30:30.000Z', '', 'fr-FR')
And returns the result 15/03/2018 13:00:00.
startOfMonth
Return the start of the month for a timestamp in an optional locale format.
startOfMonth('', ''?, ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<timestamp> | Yes | string | The string that contains the timestamp |
<format> | No | string | A custom format pattern. Default is UTC ISO format (YYYY-MM-DDTHH:mm:ss.fffZ), compliant with ISO 8601. |
<locale> | No | string | An optional locale of culture information |
Return Value | Type | Description |
---|---|---|
<updated-timestamp> | string | The specified timestamp starting on the first day of the month at the zero-hour mark |
Example 1
This example finds the start of the month:
startOfMonth('2018-03-15T13:30:30.000Z')
And returns the result 2018-03-01T00:00:00.000Z.
Example 2
This example finds the start of the month with the locale fr-FR:
startOfMonth('2018-03-15T13:30:30.000Z', '', 'fr-FR')
And returns the result 01/03/2018 00:00:00.
startsWith
Check whether a string starts with a specific substring. Return true
if the substring is found, or return false
if not found. This function is case-insensitive.
startsWith('', '')
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The string to check |
<searchText> | Yes | string | The starting substring to find |
Return value | Type | Description |
---|---|---|
true or false | Boolean | Return true if the starting substring is found. Return false if not found |
Example 1
This example checks whether the string hello world starts with the string hello:
startsWith('hello world', 'hello')
And returns the result true
.
Example 2
This example checks whether the string hello world starts with the string greeting:
startsWith('hello world', 'greeting')
And returns the result false
.
string
Return the string version of a value in an optional locale format.
string(, ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<value> | Yes | any | The value to convert |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
<string-value> | string | The string version of the specified value |
Example 1
This example creates the string version of the number 10:
string(10)
And returns the string result 10.
Example 2
This example creates a string for the specified JSON object and uses the backslash character,\\, as an escape character for the double-quotation mark character, ".
string( { "name": "Sophie Owen" } )
And returns the result { "name": "Sophie Owen" }
Example 3
These example creates a string version of the number 10 in a specific locale:
string(100.1, 'fr-FR')
string(100.1, 'en-US')
And returns the following strings respectively:
- 100,1
- 100.1
stringOrValue
Wrap string interpolation to get the real value. For example, stringOrValue('${1}')
returns the number 1, while stringOrValue('${1} item')
returns the string "1 item".
stringOrValue()
Parameter | Required | Type | Description |
---|---|---|---|
<string> | Yes | string | The string to get the real value from. |
Return value | Type | Description |
---|---|---|
<result> | any | The result of getting the real value of the specified string. |
Examples
These examples get the real value from the string:
stringOrValue('${one}')
stringOrValue('${one} item')
And return the following results respectively:
- The number 1.0.
- The string 1 item.
sub
Return the result from subtracting the second number from the first number.
sub(, )
Parameter | Required | Type | Description |
---|---|---|---|
<minuend> | Yes | number | The number from which to subtract the subtrahend |
<subtrahend> | Yes | number | The number to subtract from the minuend |
Return value | Type | Description |
---|---|---|
<result> | number | The result from subtracting the second number from the first number |
Example
This example subtracts the second number from the first number:
sub(10.3, .3)
And returns the result 10.
subArray
Returns a subarray from specified start and end positions. Index values start with the number 0.
subArray(, , )
Parameter | Required | Type | Description |
---|---|---|---|
<array> | Yes | array | The array to create the subarray from |
<startIndex> | Yes | integer | A positive number equal to or greater than 0 to use as the starting position or index value |
<endIndex> | Yes | integer | A positive number equal to or greater than 0 to use as the ending position or index value |
Return Value | Type | Description |
---|---|---|
<subarray-result> | array | A subarray with the specified number of items, starting at the specified index position in the source array |
Example
This example creates a subarray from the specified array:
subArray(createArray('H','e','l','l','o'), 2, 5)
And returns the result ["l", "l", "o"].
substring
Return characters from a string, starting from the specified position or index. Index values start with the number 0.
substring('', , )
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The string to create the substring from |
<startIndex> | Yes | integer | A positive number equal to or greater than 0 to use as the starting position or index value |
<length> | Yes | integer | A positive number of characters to include in the substring |
Return Value | Type | Description |
---|---|---|
<substring-result> | string | A substring with the specified number of characters, starting at the specified index position in the source string |
Example
This example creates a five-character substring from the specified string, starting from the index value 6:
substring('hello world', 6, 5)
And returns the result world.
subtractFromTime
Subtract a number of time units from a timestamp in an optional locale format. See also getPastTime().
subtractFromTime('', , '', ''?, ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<timestamp> | Yes | string | The string that contains the timestamp |
<interval> | Yes | integer | The number of specified time units to subtract |
<timeUnit> | Yes | string | The unit of time to use with the interval. Possible units are "Second", "Minute", "Hour", "Day", "Week", "Month", and "Year". |
<format> | No | string | A custom format pattern. Default is UTC ISO format (YYYY-MM-DDTHH:mm:ss.fffZ), compliant with ISO 8601. |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
<updated-timestamp> | string | The timestamp minus the specified number of time units |
Example 1
This example subtracts one day from a following timestamp:
subtractFromTime('2018-01-02T00:00.000Z', 1, 'Day')
And returns the result 2018-01-01T00:00:00.000Z.
Example 2
This example subtracts one day from a timestamp using the D format:
subtractFromTime('2018-01-02T00:00.000Z', 1, 'Day', 'D')
And returns the result Monday, January, 1, 2018.
Example 3
This example subtracts 1 hour from a timestamp in the de-DE locale:
subtractFromTime('2018-03-15T13:00:00.000Z', 1, 'Hour', '', 'de-DE')
And returns the result 15.03.18 12:00:00.
sum
Return the result from adding numbers in a list.
sum([])
Parameter | Required | Type | Description |
---|---|---|---|
[<list of numbers>] | Yes | array of numbers | The numbers to add |
Return value | Type | Description |
---|---|---|
<result-sum> | number | The result from adding the specified numbers |
Example
This example adds the specified numbers:
sum(createArray(1, 1.5))
And returns the result 2.5.
take
Return items from the front of a collection.
take('', )
take([], )
Parameter | Required | Type | Description |
---|---|---|---|
<collection> | Yes | string or array | The collection whose items you want |
<count> | Yes | integer | A positive integer for the number of items you want from the front |
Return Value | Type | Description |
---|---|---|
<subset> or [<subset>] | string or array | A string or array with the specified number of items taken from the front of the original collection |
Example
These examples get the specified number of items from the front of these collections:
take('abcde', 3)
take(createArray(0, 1, 2, 3, 4), 3)
And return the following results respectively:
- abc
- [0, 1, 2]
ticks
Return the ticks property value of a specified timestamp. A tick is 100-nanosecond interval.
ticks('')
Parameter | Required | Type | Description |
---|---|---|---|
<timestamp> | Yes | string | The string for a timestamp |
Return value | Type | Description |
---|---|---|
<ticks-number> | integer (bigint in JavaScript) | The number of ticks since the specified timestamp |
Example
This example converts a timestamp to its ticks property:
ticks('2018-01-01T08:00:00.000Z')
And returns the result 636503904000000000.
ticksToDays
Convert a ticks property value to the number of days.
ticksToDays('ticks')
Parameter | Required | Type | Description |
---|---|---|---|
<ticks> | Yes | integer | The ticks property value to convert |
Return value | Type | Description |
---|---|---|
<number-of-days> | number | The number of days converted from the ticks property value |
Example
This example converts a ticks property value to a number of days:
ticksToDays(2193385800000000)
And returns the number 2538.64097222.
ticksToHours
Convert a ticks property value to the number of hours.
ticksToHours('ticks')
Parameter | Required | Type | Description |
---|---|---|---|
<ticks> | Yes | Integer | The ticks property value to convert |
Return value | Type | Description |
---|---|---|
<number-of-hours> | number | The number of hours converted from the ticks property value |
Example
This example converts a ticks property value to a number of hours:
ticksToHours(2193385800000000)
And returns the number 60927.383333333331.
ticksToMinutes
Convert a ticks property value to the number of minutes.
ticksToMinutes('ticks')
Parameter | Required | Type | Description |
---|---|---|---|
<ticks> | Yes | integer | The ticks property value to convert |
Return value | Type | Description |
---|---|---|
<number-of-minutes> | number | The number of minutes converted from the ticks property value |
Example
This example converts a ticks property value to a number of minutes:
ticksToMinutes(2193385800000000)
And returns the number 3655643.0185.
titleCase
Capitalize the first letter of each word in a string in an optional local format.
titleCase('', ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The original string |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
result string | string | The title case result |
Example 1
These examples capitalize the first letter of each word in a string:
titleCase('a')
titleCase('abc def')
titleCase('aBC dEF')
And return the following results respectively:
- A
- Abc Def
- Abc Def
Example 2
These examples capitalize the first letter in a string in the en-US format:
titleCase('a', 'en-US')
titleCase('aBC dEF', 'en-US')
And return the following results respectively:
- A
- Abc Def
toLower
Return a string in lowercase in an optional locale format. If a character in the string doesn't have a lowercase version, that character stays unchanged in the returned string.
toLower('', ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The string to return in lowercase format |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
<lowercase-text> | string | The original string in lowercase format |
Example 1
This example converts a string to lowercase:
toLower('Hello World')
And returns the result hello world.
Example 2
This example converts a string to lowercase in the fr-FR format:
toUpper('Hello World', 'fr-FR')
And returns the result hello world.
toUpper
Return a string in uppercase in an optional locale format. If a character in the string doesn't have an uppercase version, that character stays unchanged in the returned string.
toUpper('', ''?)
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The string to return in uppercase format |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
<uppercase-text> | string | The original string in uppercase format |
Example 1
This example converts a string to uppercase:
toUpper('Hello World')
And returns the result HELLO WORLD.
Example 2
This example converts a string to uppercase in the fr-FR format:
toUpper('Hello World', 'fr-FR')
And returns the result HELLO WORLD.
trim
Remove leading and trailing whitespace from a string, and return the updated string.
trim('')
Parameter | Required | Type | Description |
---|---|---|---|
<text> | Yes | string | The string that has the leading and trailing whitespace to remove |
Return Value | Type | Description |
---|---|---|
<updatedText> | string | An updated version of the original string without leading or trailing whitespace |
Example
This example removes the leading and trailing whitespace from the string " Hello World ":
trim(' Hello World ')
And returns the trimmed result Hello World.
union
Return a collection that has all the items from the specified collections. To appear in the result, an item can appear in any collection passed to this function. If one or more items have the same name, the last item with that name appears in the result.
union('', '', ...)
union([], [], ...)
Parameter | Required | Type | Description |
---|---|---|---|
<collection1> , <collection2> , ... | Yes | array or object, but not both | The collections from where you want all the items |
Return Value | Type | Description |
---|---|---|
<updatedCollection> | array or object, respectively | A collection with all the items from the specified collections. No duplicates added. |
Example
This example gets all the items from the following collections:
union(createArray(1, 2, 3), createArray(1, 2, 10, 101))
And returns the result [1, 2, 3, 10, 101].
unique
Remove all duplicates from an array.
unique([])
Parameter | Required | Type | Description |
---|---|---|---|
<collection> | Yes | array | The collection to modify |
Return value | Type | Description |
---|---|---|
<new-collection> | array | New collection with duplicate elements removed |
Example 1
This example removes duplicate elements from the following array:
unique(createArray(1, 2, 1))
And returns the result [1, 2].
uriComponent
Return the binary version of a uniform resource identifier (URI) component.
uriComponent('')
Parameter | Required | Type | Description |
---|---|---|---|
<value> | Yes | string | The string to convert to URI-encoded format |
Return value | Type | Description |
---|---|---|
<encoded-uri> | string | The URI-encoded string with escape characters |
Example
This example creates a URI-encoded version of a string:
uriComponent('https://contoso.com')
And returns the result http%3A%2F%2Fcontoso.com.
uriComponentToString
Return the string version of a uniform resource identifier (URI) encoded string, effectively decoding the URI-encoded string.
uriComponentToString('')
Parameter | Required | Type | Description |
---|---|---|---|
<value> | Yes | string | The URI-encoded string to decode |
Return value | Type | Description |
---|---|---|
<binary-for-encoded-uri> | string | The decoded version for the URI-encoded string |
Example
This example creates the decoded string version of a URI-encoded string:
uriComponentToString('http%3A%2F%2Fcontoso.com')
And returns the result https://contoso.com
.
uriHost
Return the host value of a unified resource identifier (URI).
uriHost('')
Parameter | Required | Type | Description |
---|---|---|---|
<uri> | Yes | string | The URI whose host value you want |
Return value | Type | Description |
---|---|---|
<host-value> | string | The host value of the specified URI |
Example
This example finds the host value of the following URI:
uriHost('https://www.localhost.com:8080')
And returns the result www.localhost.com
.
uriPath
Return the path value of a unified resource identifier (URI).
uriPath('')
Parameter | Required | Type | Description |
---|---|---|---|
<uri> | Yes | string | The URI whose path value you want |
Return value | Type | Description |
---|---|---|
<path-value> | string | The path value of the specified URI |
Example
This example finds the path value of the following URI:
uriPath('http://www.contoso.com/catalog/shownew.htm?date=today')
And returns the result /catalog/shownew.htm.
uriPathAndQuery
Return the path and query value of a unified resource identifier (URI).
uriPathAndQuery('')
Parameter | Required | Type | Description |
---|---|---|---|
<uri> | Yes | string | The URI whose path and query value you want |
Return value | Type | Description |
---|---|---|
<path-query-value> | string | The path and query value of the specified URI |
Example
This example finds the path and query value of the following URI:
uriPathAndQuery('http://www.contoso.com/catalog/shownew.htm?date=today')
And returns the result /catalog/shownew.htm?date=today.
uriPort
Return the port value of a unified resource identifier (URI).
uriPort('')
Parameter | Required | Type | Description |
---|---|---|---|
<uri> | Yes | string | The URI whose path value you want |
Return value | Type | Description |
---|---|---|
<port-value> | string | The port value of the specified URI |
Example
This example finds the port value of the following URI:
uriPort('http://www.localhost:8080')
And returns the result 8080.
uriQuery
Return the query value of a unified resource identifier (URI).
uriQuery('')
Parameter | Required | Type | Description |
---|---|---|---|
<uri> | Yes | string | The URI whose query value you want |
Return value | Type | Description |
---|---|---|
<query-value> | string | The query value of the specified URI |
Example
This example finds the query value of the following URI:
uriQuery('http://www.contoso.com/catalog/shownew.htm?date=today')
And returns the result ?date=today.
uriScheme
Return the scheme value of a unified resource identifier (URI).
uriScheme('')
Parameter | Required | Type | Description |
---|---|---|---|
<uri> | Yes | string | The URI whose query value you want |
Return value | Type | Description |
---|---|---|
<scheme-value> | string | The scheme value of the specified URI |
Example
This example finds the scheme value of the following URI:
uriQuery('http://www.contoso.com/catalog/shownew.htm?date=today')
And returns the result http.
utcNow
Return the current timestamp in an optional locale format as a string.
utcNow('', ''?)
Optionally, you can specify a different format with the <format> parameter.
Parameter | Required | Type | Description |
---|---|---|---|
<format> | No | string | A custom format pattern. The default format for the timestamp is UTC ISO format (YYYY-MM-DDTHH:mm:ss.fffZ), compliant with ISO 8601. |
<locale> | No | string | An optional locale of culture information |
Return value | Type | Description |
---|---|---|
<current-timestamp> | string | The current date and time |
Example 1
Suppose the date is April 15, 2018 at 1:00:00 PM. This example gets the timestamp:
utcNow()
And returns the result 2018-04-15T13:00:00.000Z.
Example 2
Suppose the date is April 15, 2018 at 1:00:00 PM. This example gets the current timestamp using the optional D format:
utcNow('D')
And returns the result Sunday, April 15, 2018.
Example 3
Suppose the date is April 15, 2018 at 1:00:00 PM. This example gets the current timestamp using the de-DE locale:
utcNow('', 'de-DE')
And returns the result 15.04.18 13:00:00.
Updated about 1 month ago