String
For a string containing just A-Z characters, use
{{$string.alpha}}
. To add digits too, use {{$string.alphanumeric}}
. If you only want punctuation marks/symbols, use {{$string.symbol}}
. For a full set of ASCII characters, use {{$string.sample}}
. For a custom set of characters, use {{$string.fromCharacters}}
.{{$string.numeric}}
. For other bases, use {{$string.binary}}
, {{$string.octal}}
, or {{$string.hexadecimal}}
).{{$string.uuid}}
or {{$string.nanoid}}
.Emoji can be found at
{{$internet.emoji}}
.The Helpers module includes a number of string related methods.
alpha
Name | Type | Default | Description |
---|---|---|---|
casing | Casing | mixed | The casing of the characters. |
exclude | string | Array<AlphaChar | string> | [] | An array with characters which should be excluded in the generated string. |
min | number | 1 | The minimum number of characters to generate. |
max | number | 1 | The maximum number of characters to generate. |
length | number | 1 | The range of characters to generate. |
alphanumeric
Name | Type | Default | Description |
---|---|---|---|
casing | Casing | mixed | The casing of the characters. |
exclude | string | Array<AlphaNumericChar | string> | [] | An array with characters which should be excluded in the generated string. |
min | number | 1 | The minimum number of characters to generate. |
max | number | 1 | The maximum number of characters to generate. |
length | number | 1 | The range of characters to generate. |
binary
Name | Type | Default | Description |
---|---|---|---|
prefix | string | 0b | Prefix for the generated number. |
min | number | 1 | The minimum number of characters to generate after the prefix. |
max | number | 1 | The maximum number of characters to generate after the prefix. |
length | number | 1 | The range of characters to generate. |
fromCharacters
Name | Type | Default | Description |
---|---|---|---|
characters | string | string[] | The characters to use for the string. Can be a string or an array of characters. If it is an array, then each element is treated as a single character even if it is a string with multiple characters. | |
min | number | The minimum length of the string to generate. | |
max | number | The maximum length of the string to generate. |
hexadecimal
Name | Type | Default | Description |
---|---|---|---|
casing | Casing | mixed | The casing of the characters. |
prefix | string | 0x | Prefix for the generated number. |
min | number | 1 | The minimum number of characters to generate after the prefix. |
max | number | 1 | The maximum number of characters to generate after the prefix. |
length | number | 1 | The range of characters to generate after the prefix. |
nanoid
Name | Type | Default | Description |
---|---|---|---|
min | number | 1 | The minimum length of the Nano ID to generate. |
max | number | 1 | The maximum length of the Nano ID to generate. |
length | number | 21 | Length of the generated string. |
numeric
Name | Type | Default | Description |
---|---|---|---|
exclude | string | Array<NumericChar | string> | [] | An array of digits which should be excluded in the generated string. |
allowLeadingZeros | boolean | true | Whether leading zeros are allowed or not. |
min | number | 1 | The minimum of digits to generate. |
max | number | 1 | The maximum of digits to generate. |
length | number | 1 | The range of digits to generate. |
octal
Name | Type | Default | Description |
---|---|---|---|
min | number | 1 | The minimum of digits to generate after the prefix. |
max | number | 1 | The maximum of digits to generate after the prefix. |
length | number | 1 | The range of digits to generate after the prefix. |
prefix | string | 0o | Prefix for the generated number. |
sample
!
to }
).Name | Type | Default | Description |
---|---|---|---|
min | number | The minimum number of characters to generate. | |
max | number | The maximum number of characters to generate. |
symbol
Name | Type | Default | Description |
---|---|---|---|
min | number | The minimum number of special characters to generate. | |
max | number | The maximum number of special characters to generate. |
uuid