String

Methods

htmlDecode(str) → {String} static

Decodes html into it's string contents.

Parameters:

NameTypeDescription
strString

The string to decode.

Returns:

The decoded string.

parseQueryString(str) → {Object} static

Parses a url parameter string into an object.

Parameters:

NameTypeDescription
strString

The string to parse.

Returns:

The object representation of the parsed string.

sprintf(fmt) → {String} static

Returns a string produced according to the formatting string fmt.

Parameters:

NameTypeDescription
fmtString

The format string is composed of zero or more directives: ordinary characters (excluding %) that are copied directly to the result, and conversion specifications, each of which results in fetching its own parameter.

  • % - a literal percent character. No argument is required.
  • b - the argument is treated as an integer, and presented as a binary number.
  • c - the argument is treated as an integer, and presented as the character with that ASCII value.
  • d - the argument is treated as an integer, and presented as a (signed) decimal number.
  • e - the argument is treated as scientific notation (e.g. 1.2e+2). The precision specifier stands for the number of digits after the decimal point since PHP 5.2.1. In earlier versions, it was taken as number of significant digits (one less).
  • E - like %e but uses uppercase letter (e.g. 1.2E+2).
  • f - the argument is treated as a float, and presented as a floating-point number (locale aware).
  • F - the argument is treated as a float, and presented as a floating-point number (non-locale aware). Available since PHP 4.3.10 and PHP 5.0.3.
  • g - shorter of %e and %f.
  • G - shorter of %E and %f.
  • o - the argument is treated as an integer, and presented as an octal number.
  • s - the argument is treated as and presented as a string.
  • u - the argument is treated as an integer, and presented as an unsigned decimal number.
  • x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).
  • X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).

Returns:

The formatted string.

vsprintf(fmt, str) → {String} static

Return a formatted string. Operates as String.sprintf() but accepts an array of arguments, rather than a variable number of arguments.

Parameters:

NameTypeDescription
fmtString

The string to use as format.

strArray

The items to use in the format.

Returns:

The formatted string.

camelize() → {String}

Converts string to camel case.

Returns:

The string in camel case.

capitalize() → {String}

Converts the first character of string to upper case and the remaining to lower case.

Returns:

The capitalized string.

clean() → {String}

Cleans the string from whitespace characters.

Returns:

The cleaned string.

contains(value) → {Boolean}

Returns true of false based on whether value is in string or not.

Parameters:

NameTypeDescription
valueString

Value to check for.

Returns:

dasherize() → {String}

Converts string to dash case.

Returns:

The dasherized string.

endsWith(searchString, position) → {Boolean}

Determines whether a string ends with the characters of a specified string, returning true or false as appropriate.

Parameters:

NameTypeArgumentDescription
searchStringString

The characters to be searched for at the end of this string.

positionNumberoptional 

If provided starts the match from the length of the string minus the second argument. If omitted, the default value is the length of the string.

Returns:

true if the given characters are found at the end of the string; otherwise, false.

htmlEscape() → {String}

Escapes html entities (&"'<>) within the string.

Returns:

The html escaped string.

hyphenate() → {String}

Converts string to hyphen case.

Returns:

The hyphenated string.

includes(searchString, position) → {Boolean}

Determines whether one string may be found within another string, returning true or false as appropriate.

Parameters:

NameTypeArgumentDefaultDescription
searchStringString

A string to be searched for within this string.

positionNumberoptional 0

The position within the string at which to begin searching for searchString.

Returns:

true if the given string is found anywhere within the search string; otherwise, false if not.

repeat(count, separator) → {String}

Repeats the given string n times.

Parameters:

NameTypeArgumentDefaultDescription
countNumber

Number times the string should be repeated.

separatorStringoptional ''

Optional separator between each repetition of the string.

Returns:

The repeated string.

reverse() → {String}

Reverses the string.

Returns:

The reversed string.

startsWith(searchString, position) → {Boolean}

Determines whether a string begins with the characters of a specified string, returning true or false as appropriate.

Parameters:

NameTypeArgumentDefaultDescription
searchStringString

The characters to be searched for at the start of this string.

positionNumberoptional 0

The position in this string at which to begin searching for searchString.

Returns:

true if the given characters are found at the beginning of the string; otherwise, false.

stripTags(tag, contents) → {String}

Strips html tags from the string.

Parameters:

NameTypeArgumentDefaultDescription
tagString

Tag to strip from the string.

contentsBooleanoptional false

Remove the contents of the tags.

Returns:

The stripped string.

trim() → {String}

Removes leading and trailing whitespace from string.

Returns:

The trimmed string.

truncate(end) → {String}

Truncates string if it’s longer than the given maximum string length.

Parameters:

NameTypeDescription
endNumber

Maximum string length.

Returns:

The truncated string.