xtr.strings¶
appendIfMissing¶
appendIfMissing(str1: String, str2: String): String
Returns str1, appended with str2 if it does not already end with str2.
Example
Resultcapitalize¶
capitalize(str: String): String
Returns the capitalized version of str, by capitalizing the first letter of every word.
Example
ResultcharCode¶
charCode(str: String): Number
Returns the character-code for the given str, a single character.
Example
ResultcharCodeAt¶
charCodeAt(str: String, num: Number): Number
Returns the character-code for the character at the given num index in str.
Example
ResultofCharCode¶
ofCharCode(num: Number): String
Returns the character for the given character-code.
Example
ResultisAlpha¶
isAlpha(str: String|Number|Boolean): Boolean
Returns true if the given str contains only alphabetic characters, otherwise false.
Example
ResultisAlphanumeric¶
isAlphanumeric(str: String|Number|Boolean): Boolean
Returns true if the given str contains only alphanumeric characters, otherwise false.
Example
ResultisLowerCase¶
isLowerCase(str: String): Boolean
Returns true if the alphabetic characters in the given str are all lowercase, otherwise false.
Example
ResultisNumeric¶
isNumeric(str: String|Number|Boolean): Boolean
Returns true if the given str contains only numeric characters.
Example
ResultisUpperCase¶
isUpperCase(str: String): Boolean
Returns true if the alphabetic characters in the given str are all uppercase, otherwise false.
Example
ResultleftPad¶
leftPad(str: String|Number, offset: Number, pad: String): String
Returns str prepended with enough repetitions of pad required to meet the given offset size; a str already that long -- including any negative or zero offset -- is returned unchanged. Only the first character of pad is used, and an empty pad is an error. A Number value for str is stringified the same way as xtr.toString.
Example
Resultmatch¶
match(str: String, regex: String): Array[String|Null] | Null
Matches the entire str against the given Java regular expression regex.
Returns an Array with the entire match followed by the value of each capture group, where groups that did not participate in the match are null. Returns null if str does not match, which composes with the ?? operator.
Example
Resultmatches¶
matches(str: String, regex: String): Boolean
Reports whether the entire str matches the given Java regular expression regex.
Example
ResultnumOrdinalOf¶
numOrdinalOf(num: Number|String): String
Returns the numeric ordinal name for the given num. A String is accepted if its contents are numeric; anything else is an error.
Example
Resultpluralize¶
pluralize(value: String): String
Returns the plural of the given value.
Example
ResultprependIfMissing¶
prependIfMissing(str1: String, str2: String): String
Returns str1, prepended with str2 if it does not already start with str2.
Example
Resultrepeat¶
repeat(str: String, num: Number): String
Returns str repeated num times.
Example
ResultrightPad¶
rightPad(str: String|Number, offset: Number, pad: String): String
Returns str appended with enough repetitions of pad required to meet the given offset size; a str already that long -- including any negative or zero offset -- is returned unchanged. Only the first character of pad is used, and an empty pad is an error. A Number value for str is stringified the same way as xtr.toString.
Example
Resultscan¶
scan(str: String, regex: String): Array[Array[String|Null]]
Finds every match of the given Java regular expression regex within str.
Returns an Array with one element per match, each an Array of the entire match followed by the value of each capture group, where groups that did not participate in the match are null. Returns an empty Array if there are no matches.
Example
Resultsingularize¶
singularize(value: String): String
Returns the singular of the given value.
Example
ResultsubstringAfter¶
substringAfter(value: String, sep: String): String
Returns the contents of value after the first occurrence of sep, or an empty String if value does not contain sep.
Example
ResultsubstringAfterLast¶
substringAfterLast(value: String, sep: String): String
Returns the contents of value after the last occurrence of sep, or an empty String if value does not contain sep.
Example
ResultsubstringBefore¶
substringBefore(value: String, sep: String): String
Returns the contents of value before the first occurrence of sep, or an empty String if value does not contain sep.
Example
ResultsubstringBeforeLast¶
substringBeforeLast(value: String, sep: String): String
Returns the contents of value before the last occurrence of sep, or an empty String if value does not contain sep.
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(value: String, wrapper: String): String
Returns value without the given wrapper as prefix and suffix, when both are present. When only one is present it is moved to the other side: a prefix-only match strips the prefix and appends the wrapper, a suffix-only match strips the suffix and prepends it.
Example
Resultwrap¶
wrap(value: String, wrapper: String): String
Returns str, prepended and appended with wrap.
Example
ResultwrapIfMissing¶
wrapIfMissing(value: String, wrapper: String): String
Returns str, prepended and appended with wrap, if not found.
Example
Result