xtr.strings¶
appendIfMissing¶
appendIfMissing(str: String, suffix: String): String
Returns str
, appended with suffix
if it does not already end with suffix
.
Example
Resultcapitalize¶
capitalize(str: String): String
Returns the capitalized version of str
, by capitalizing the first letter of every word.
Example
ResultcharCode¶
charCode(char: String): String
Returns the character-code for the given char
.
Example
ResultcharCodeAt¶
charCodeAt(str: String, index: Number): String
Returns the character-code for the character at the given index
in str
.
Example
ResultofCharCode¶
ofCharCode(code: Number): String
Returns the character for the given character-code.
Example
ResultisAlpha¶
isAlpha(str: String): String
Returns true
if the given str
contains only alphabetic characters, otherwise false
.
Example
ResultisAlphanumeric¶
isAlphanumeric(str: String): String
Returns true
if the given str
contains only alphanumeric characters, otherwise false
.
Example
ResultisLowerCase¶
isLowerCase(str: String): String
Returns true
if the alphabetic characters in the given str
are all lowercase, otherwise false
.
Example
ResultisNumeric¶
isNumeric(str: String): String
Returns true
if the given str
contains only numeric characters.
Example
ResultisUpperCase¶
isUpperCase(str: String): String
Returns true
if the alphabetic characters in the given str
are all uppercse, otherwise false
.
Example
ResultleftPad¶
leftPad(str: String, size: Number, char: String): String
Returns str
prepended with enough repetitions of char
required to meet the given size
, otherwise returns str
if its size is already equal or longer than size
.
Example
ResultnumOrdinalOf¶
numOrdinalOf(num: Number): String
Returns the numeric ordinal name for the given num
.
Example
Resultpluralize¶
pluralize(word: String): String
Returns the plural of the given word
.
Example
ResultprependIfMissing¶
prependIfMissing(str: String, prefix: String): String
Returns str
, prepended with prefix
if it does not already start with prefix
.
Example
Resultrepeat¶
repeat(str: String, n: Number): String
Returns str
repeated n
times.
Example
ResultrightPad¶
rightPad(str: String, size: Number, char: String): String
Returns str
prepended with enough repetitions of char
required to meet the given size
, otherwise returns str
if its size is already equal or longer than size
.
Example
Resultsingularize¶
singularize(word: String): String
Returns the singular of the given word
.
Example
ResultsubstringAfter¶
substringAfter(str1: String, str2: String): String
Returns the contents of str1
after the first occurrence of str2
, otherwise returns str1
if it does not contain str2
.
Example
ResultsubstringAfterLast¶
substringAfterLast(str1: String, str2: String): String
Returns the contents of str1
after the last occurrence of str2
, otherwise returns str1
if it does not contain str2
.
Example
ResultsubstringBefore¶
substringBefore(str1: String, str2: String): String
Returns the contents of str1
before the first occurrence of str2
, otherwise returns str1
if it does not contain str2
.
Example
ResultsubstringBeforeLast¶
substringBeforeLast(str1: String, str2: String): String
Returns the contents of str1
before the last occurrence of str2
, otherwise returns str1
if it does not contain str2
.
Example
ResulttoCamelCase¶
toCamelCase(str: String): String
Returns the toCamelCased version of str
, by removing all spaces and underscores, and capitalizing the first letter of every word after the first.
Example
ResulttoKebabCase¶
toKebabCase(str: String): String
Returns the kebab-case version of str
, by changing alphabetic characters to lowercase, and replacing all spaces and underscores for dashes.
Example
ResulttoSnakeCase¶
toSnakeCase(str: String): String
Returns the snake_case version of the given str
, by prepending uppercase characters with an underscore, changing alphabetic characters to lowercase, and replacing all spaces for underscores.
Example
Resultunwrap¶
unwrap(str: String, wrap: String): String
Returns str
without the given wrap
as prefix and suffix, if found.
Example
Resultwrap¶
wrap(str: String, wrap: String): String
Returns str
, prepended and appended with wrap
.
Example
ResultwrapIfMissing¶
wrapIfMissing(str: String, wrap: String): String
Returns str
, prepended and appended with wrap
, if not found.
Example
Result