Takes a string and replaces instances of markers with values in the given array.
The markers take the form of %1
, %2
, etc. I.e.:
Format("The %1 is worth %2 gold", [ 'Sword', 500 ])
name | type | description |
---|---|---|
string | string |
The string containing the replacement markers. |
values | array |
An array containing values that will replace the markers. If no value exists an empty string is inserted instead. |
The string containing replaced values.
Takes the given string and pads it out, to the length required, using the character specified. For example if you need a string to be 6 characters long, you can call:
pad('bob', 6, '-', 2)
This would return: bob---
as it has padded it out to 6 characters, using the -
on the right.
You can also use it to pad numbers (they are always returned as strings):
pad(512, 6, '0', 1)
Would return: 000512
with the string padded to the left.
If you don't specify a direction it'll pad to both sides:
pad('c64', 7, '*')
Would return: **c64**
name | type | arguments | Default | description |
---|---|---|---|---|
str | string | number | object |
The target string. |
||
len | number | <optional> | 0 |
The number of characters to be added. |
pad | string | <optional> | " " |
The string to pad it out with (defaults to a space). |
dir | number | <optional> | 3 |
The direction dir = 1 (left), 2 (right), 3 (both). |
The padded string.
Takes a string and removes the character at the given index.
name | type | description |
---|---|---|
string | string |
The string to be worked on. |
index | number |
The index of the character to be removed. |
The modified string.
Takes the given string and reverses it, returning the reversed string.
For example if given the string Atari 520ST
it would return TS025 iratA
.
name | type | description |
---|---|---|
string | string |
The string to be reversed. |
The reversed string.
Capitalizes the first letter of a string if there is one.
name | type | description |
---|---|---|
str | string |
The string to capitalize. |
A new string, same as the first, but with the first letter capitalized.
UppercaseFirst('abc');
// returns 'Abc'
UppercaseFirst('the happy family');
// returns 'The happy family'
UppercaseFirst('');
// returns ''
Creates and returns an RFC4122 version 4 compliant UUID.
The string is in the form: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
where each x
is replaced with a random
hexadecimal digit from 0 to f, and y
is replaced with a random hexadecimal digit from 8 to b.
The UUID string.