Class: StrUtils

StrUtils

new StrUtils()

A class with some help methods to manipulate string.
Source:

Methods

(static) addTokens(str, tokens, separator)

Add token(s) to str. Tokens can be a string or separator split string or array. If separator is not provided, space will be used.
Parameters:
Name Type Description
str String
tokens Variant
separator String
Source:

(static) boolToStr(value) → {String}

Turn a boolean to a string value, use Kekule.StrUtils.STR_TRUES constants.
Parameters:
Name Type Description
value Bool
Source:
Returns:
Type
String

(static) convertToStr(value) → {String}

Convert a simple value to string.
Parameters:
Name Type Description
value Variant
Source:
Returns:
Type
String

(static) convertToType(str, valueType) → {Variant}

Convert str to a specified typed value.
Parameters:
Name Type Description
str String
valueType String A simple type, data from DataType.
Source:
Returns:
Type
Variant

(static) getLineCount(str, lineDelimiter) → {Int}

Returns the total line count of string.
Parameters:
Name Type Description
str String
lineDelimiter String Default is "\n".
Source:
Returns:
Type
Int

(static) getMaxLineCharCount(str, lineDelimiter) → {Int}

Returns maxium char count in each line of str.
Parameters:
Name Type Description
str String
lineDelimiter String Default is "\n".
Source:
Returns:
Type
Int

(static) hasToken(str, token, separator)

Check if token already inside str.
Parameters:
Name Type Description
str
token
separator
Source:

(static) isNumbericStr(str) → {Bool}

Check if str is in number format.
Parameters:
Name Type Description
str String
Source:
Returns:
Type
Bool

(static) normalizeSpace(str) → {String}

Replace repeated spaces, newlines and tabs with a single space
Parameters:
Name Type Description
str String
Source:
Returns:
Type
String

(static) removeAroundPair(str, leading, tailing)

If str start with leading and end with tailing, remove both of them.
Parameters:
Name Type Description
str String
leading String
tailing String
Source:

(static) removeTokens(str, tokens, separator)

Remove token(s) to str. Tokens can be a string or separator split string or array. If separator is not provided, space will be used.
Parameters:
Name Type Description
str String
tokens Variant
separator String
Source:

(static) splitIndexEndingStr(str) → {Object}

Split a number ending string (e.g. 'str3') to two part, a prefix and an index. If the str is not ending with number, null will be returned.
Parameters:
Name Type Description
str String
Source:
Returns:
A object of {prefix, index}
Type
Object

(static) splitTokens(str, separator) → {Array}

Split string into tokens with separator. If separator is not provided, space will be used. Space around tokens will be emitted too.
Parameters:
Name Type Description
str String
separator String
Source:
Returns:
Type
Array

(static) strToBool(value) → {Bool}

Convert a string to boolean value.
Parameters:
Name Type Description
value String
Source:
Returns:
Type
Bool

(static) toggleTokens(str, tokens, separator)

Token token(s) in str. Tokens can be a string or separator split string or array. If separator is not provided, space will be used.
Parameters:
Name Type Description
str String
tokens Variant
separator String
Source:

(static) trim(str) → {String}

Trim leading and trailing space, tabs or line-breaks of string
Parameters:
Name Type Description
str String
Source:
Returns:
Type
String

(static) unquote(str) → {String}

Remove leading and tailing ' or " of str.
Parameters:
Name Type Description
str String
Source:
Returns:
Type
String