Namespace: String

utilx. String

utilx.String
Source:

Methods

(static) clipDuplicates(str) → {string}

Removes any duplicate characters from the provided string.
Parameters:
Name Type Description
str string String to remove duplicate characters from.
Source:
Returns:
String with any duplicate characters removed.
Type
string

(static) contains(string, searchString, positionopt) → {boolean}

Determines whether a string contains the characters of another string, returning true or false as appropriate.
Parameters:
Name Type Attributes Description
string string
searchString string
position number <optional>
Source:
See:
Returns:
Type
boolean

(static) countCharacter(inputArg, character) → {number}

Coerces inputArg to a string and counts the occurences of the argument character. Throws an error if the arguments can not be coerced, i.e. null or undefined.
Parameters:
Name Type Description
inputArg string
character string
Source:
Returns:
Type
number

(static) endsWith(string, searchString, positionopt) → {boolean}

Determines whether a string ends with the characters of another string, returning true or false as appropriate.
Parameters:
Name Type Attributes Description
string string
searchString string
position number <optional>
Source:
See:
Returns:
Type
boolean

(static) escapeRegex(string) → {string}

This method takes a string and puts a backslash in front of every character that is part of the regular expression syntax. This is useful if you have a run-time string that you need to match in some text and the string may contain special regex characters. Throws an error if the argument can not be coerced, i.e. null or undefined.
Parameters:
Name Type Description
string string
Source:
Returns:
Type
string

(static) first(inputArg) → {string}

Coerces its argument to a string and returns the first character of that string. If the argument is an empty string, returns an empty string. Throws an error if the argument can not be coerced, i.e. null or undefined.
Parameters:
Name Type Description
inputArg string
Source:
Returns:
Type
string

(static) isDigits(string) → {boolean}

This method returns true if the operand inputArg is a String and only contains numerical digits.
Parameters:
Name Type Description
string *
Source:
Returns:
Type
boolean

(static) isEmpty(inputArg) → {boolean}

Returns true if the operand inputArg is an empty string (ie '').
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) isEmptyAny(inputArg) → {boolean}

Returns true if the operand inputArg is an empty string literal or object (ie '').
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) isEmptyObject(inputArg) → {boolean}

Returns true if the operand inputArg is an empty string object (ie '').
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) isNotEmpty(inputArg) → {boolean}

Returns true if the operand inputArg is a string and is not empty.
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) isNotEmptyAny(inputArg) → {boolean}

Returns true if the operand inputArg is a string literal or object and is not empty.
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) isNotEmptyObject(inputArg) → {boolean}

Returns true if the operand inputArg is a string object and is not empty.
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) isString(inputArg) → {boolean}

Returns true if the operand inputArg is a string.
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) isStringAny(inputArg) → {boolean}

Returns true if the operand inputArg is a string literal or object.
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) isStringObject(inputArg) → {boolean}

Returns true if the operand inputArg is a string object.
Parameters:
Name Type Description
inputArg *
Source:
Returns:
Type
boolean

(static) last(inputArg) → {string}

Coerces its argument to a string and returns the last character of that string. If the argument is an empty string, returns an empty string. Throws an error if the argument can not be coerced, i.e. null or undefined.
Parameters:
Name Type Description
inputArg string
Source:
Returns:
Type
string

(static) match(stringArg, regExpArg) → {Array}

Fixes browser bugs in the native `String.prototype.match`.
Parameters:
Name Type Description
stringArg string String to search.
regExpArg RegExp | * Regex to search with. If not a regex object, it is passed to `RegExp`.
Source:
See:
Returns:
If `regex` uses flag g, an array of match strings or `null`. Without flag g, the result of calling `$exec(regExpArg)`.
Type
Array

(static) padLeadingChar(inputArg, character, size) → {string}

Coerces inputArg to a string and repeatedly adds the argument character to the beginning until the string is greater than or Object.equal to the specified length. Throws an error if the arguments can not be coerced, i.e. null or undefined.
Parameters:
Name Type Description
inputArg string
character string
size number
Source:
Returns:
Type
string

(static) repeat(string, times) → {string}

Repeat the current string several times, return the new string.
Parameters:
Name Type Description
string string
times number
Source:
See:
Returns:
Type
string

(static) replace(search, replacement) → {string}

Fixes browser bugs in replacement text syntax when performing a replacement using a nonregex search value, and the value of a replacement regex's `lastIndex` property during replacement iterations and upon completion. Note that this doesn't support SpiderMonkey's proprietary third (`flags`) argument.
Parameters:
Name Type Description
search RegExp | string Search pattern to be replaced.
replacement string | function Replacement string or a function invoked to create it.
Source:
See:
Returns:
New string with one or all matches replaced.
Type
string

(static) replaceAll(string, pattern, characters) → {string}

This method replaces all occurences of a string pattern within a string with the string characters. Throws an error if the argument can not be coerced, i.e. null or undefined.
Parameters:
Name Type Description
string string
pattern string | RegExp
characters string
Source:
Returns:
Type
string

(static) split(stringArg, }, limitopt) → {Array.<string>}

Splits a String object into an array of strings by separating the string into subbase.str.
Parameters:
Name Type Attributes Description
stringArg string
} string | RegExp [separator]
limit number <optional>
Source:
See:
Returns:
Type
Array.<string>

(static) startsWith(string, searchString, positionopt) → {boolean}

Determines whether a string begins with the characters of another string, returning true or false as appropriate.
Parameters:
Name Type Attributes Description
string string
searchString string
position number <optional>
Source:
See:
Returns:
Type
boolean

(static) ToString(inputArg) → {string}

The abstract operation converts its argument to a value of type string
Parameters:
Name Type Description
inputArg *
Source:
See:
Returns:
Type
string

(static) trim(inputArg) → {string}

This method removes whitespace from both ends of the string.
Parameters:
Name Type Description
inputArg string
Source:
See:
Returns:
Type
string

(static) truncate(s, n) → {string}

This method truncates a long string to the length specified by n; used by AssertionError.toString
Parameters:
Name Type Description
s string
n NumberLike
Source:
Returns:
Type
string

(static) wrapInChars(string, character) → {string}

This method wraps a string within the given character.
Parameters:
Name Type Description
string string
character string
Source:
Returns:
Type
string