Namespace: string

qui.utils.string

Methods

(static) camelize(s) → {String}

Transform a regular text to its camel-case representation.

Parameters:
Name Type Description
s String
Source:
Returns:
Type
String

(static) formatPercent(text, …args) → {String}

Replace percent-formatted placeholders in a string with given values.

Placeholders can be given as "%s", "%d" or "%f", in which case args will be used, in order, to replace them.

Placeholders can also be given as "%(name)s", "%(name)d" or "%(name)f", in which case the first argument in args will be used as an object that maps names to replacement values.

Parameters:
Name Type Attributes Description
text String
args * <repeatable>

values used to replace the placeholders

Source:
Returns:
Type
String

(static) fromUTF8(s) → {String}

Decode a string from UTF8.

Parameters:
Name Type Description
s String
Source:
Returns:
Type
String

(static) intelliSearch(s, search) → (nullable) {RegExpMatchArray}

Intelligently search for an input sequence in a string.

The input sequence is made of groups of characters separated by whitespace. Each group must be present in the searched string as it was given, without anything in between, and the groups must appear in the order in which they were given, each one starting after the previous one ends. Searching is case insensitive.

For example, "temp sens" matches "temperature sensor", while neither "tmp" nor "sens temp" does.

Parameters:
Name Type Description
s String

string to search into

search String | RegExp

string to search for, or an expression previously compiled with qui.utils.string.intelliSearchRegExp

Source:
Returns:
Type
RegExpMatchArray

(static) intelliSearchRegExp(search) → {RegExp}

Compile the regular expression used by qui.utils.string.intelliSearch.

Compiling once and passing the result to qui.utils.string.intelliSearch avoids recompiling the same expression when matching a single search string against many candidates.

Parameters:
Name Type Description
search String

the search string

Source:
Returns:
Type
RegExp

(static) replaceAll(s, oldStr, newStr) → {String}

Replace all occurrences of oldStr in s with newStr.

Parameters:
Name Type Description
s String
oldStr String
newStr String
Source:
Returns:
Type
String

(static) title(s) → {String}

Transform the starting letter of each word of a text to uppercase.

Parameters:
Name Type Description
s String
Source:
Returns:
Type
String

(static) toUTF8(s) → {String}

Encode a string to UTF8.

Parameters:
Name Type Description
s String
Source:
Returns:
Type
String

(static) uncamelize(s, chropt) → {String}

Transform a camel-case string into its dash-separated representation.

Parameters:
Name Type Attributes Description
s String
chr String <optional>

separator character (defaults to dash "-")

Source:
Returns:
Type
String