The following functions can be used to manipulate and retrieve string details from objects and variables.

These should be written in the following formats:

Click each function name in the table below for more details of it, with examples.

Functions

Function

Type

Description

CenterPad

String

Prepends and appends spaces (or specified character) to a string to form string of the desired length.

charAt

String

Returns the character in the position specified by the index parameter.

charCodeAt

Number

Returns the numeric Unicode character code of the character at the specified index.

concat

String

Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string.

fromCharCode

String

Returns a string comprising the characters represented by the Unicode character codes in the parameters.

indexOf

int

Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string.

lastIndexOf

int

Searches the string from right to left and returns the index of the last occurrence of val found before startIndex.

LeftPad

String

Prepends spaces (or specified character) to a string to form string of the desired length.

localeCompare

int

Compares the sort order of two or more strings and returns the result of the comparison as an integer.

match

Array

Matches the specifed pattern against the string.

Merge

String

Concatenate str1 and str2 together, delim is inserted between strings if both strings are not empty

replace

String

Matches the specifed pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified by repl.

RightPad

String

Appends spaces (or specified character) to a string to form string of the desired length.

search

int

Searches for the specifed pattern and returns the index of the first matching substring.

slice

String

Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character.

split

Array

Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs.

StringRepeat

String

Makes a string consisting of spaces (or of specified string) repeated count times.

StringToObject

String

Parses and converts strings with parameters into object.

substr

String

Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len.

substring

String

Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1.

ToCSV

String

Converts arguments to comma-separated string with values enclosed in qouble quotes.

toLocaleLowerCase

String

Returns a copy of this string, with all uppercase characters converted to lowercase.

toLocaleUpperCase

String

Returns a copy of this string, with all lowercase characters converted to uppercase.

toLowerCase

String

Returns a copy of this string, with all uppercase characters converted to lowercase.

toUpperCase

String

Returns a copy of this string, with all lowercase characters converted to uppercase.

Upper1

String

Upper cases the first letter of a string.

valueOf

String

Returns the primitive value of a String instance.

FormatMiles

int

Converts number to a string, e.g. "2.34 miles".

FormatNumber

int

Formats number with specified precision, e.g. "2,346".

FormatNumber2

int

Formats numbers with 2 decimal places, e.g. "2,345.56".

FormatPercent

int

Formats number as percentage, e.g. "9.1%".

CenterPad

Usage: CenterPad(str, targetLength, optional padChar = " ")

Prepends and appends spaces (or specified character) to a string to form string of the desired length.

Example:

Result:

charAt

Usage: charAt(#)

Returns the character in the position specified by the index parameter.

Example:

Result:

charCodeAt

Usage: charCodeAt(#)

Returns the numeric Unicode character code of the character at the specified index.

Example:

Result:

concat

Usage: concat(arg1,arg2,...,argN)

Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string.

Example:

Result:

fromCharCode

Usage: fromCharCode()

Returns a string comprising the characters represented by the Unicode character codes in the parameters.

Example:

Result:

indexOf

Usage: IndexOf()

Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string.

Example:

Result:

lastIndexOf

Usage: lastIndexOf()

Searches the string from right to left and returns the index of the last occurrence of val found before startIndex.

Example:

Result:

LeftPad

Usage: LeftPad(str, targetLength, optional padChar = " ")

Prepends spaces (or specified character) to a string to form string of the desired length.

Example:

Result:

localeCompare

Usage: localeCompare()

Compares the sort order of two or more strings and returns the result of the comparison as an integer.

Example:

Result:

match

Usage: match()

Matches the specified pattern against the string. Usage of "/g" allows global search (returns multiple results if there's multiple instances).

Example:

Result:

Merge

Usage: Merge(str1, str2, optional delim = " ")

Concatenate str1 and str2 together, delim is inserted between strings if both strings are not empty.

Example:

Result:

RightPad

Usage: RightPad(str, targetLength, optional padChar = " ")

Appends spaces (or specified character) to a string to form string of the desired length.

Example:

Result:

replace

Usage: replace( , )

Matches the specified pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified.

Example:

Result:

search

Usage: search()

Searches for the specified pattern and returns the index of the first matching sub-string.

Example:

Result:

slice

Usage: slice( , )

Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character.

Example:

Result:

split

Usage: split("delimiter")

Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs.

Example:

Result:

StringRepeat

Usage: StringRepeat(count, optional str = " ")

Makes a string consisting of spaces (or of specified string) repeated count times.

Example:

Result:

StringToObject

Usage: StringToObject(str, delim1, delim2, optional result = null)

Parses and converts strings with parameters into object.

Example:

Result:

substr

Usage: substr(first, last)

Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len.

Example:

Result:

substring

Usage: substring(first, last)

Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1.

Example:

Result:

ToCSV

Usage: ToCSV(...args)

Converts arguments to comma-separated string with values enclosedi in qouble quotes.

Example:

Result:

toLocaleLowerCase

Usage: toLocaleLowerCase()

Returns a copy of this string, with all uppercase characters converted to lowercase.

Example:

Result:

toLocaleUpperCase

Usage: toLocaleUpperCase()

Returns a copy of this string, with all lowercase characters converted to uppercase.

Example:

Result:

toLowerCase

Usage: toLowerCase()

Returns a copy of this string, with all uppercase characters converted to lowercase.

Example:

Result:

toUpperCase

Usage:

Returns a copy of this string, with all lowercase characters converted to uppercase.

Example:

Result:

Upper1

Usage: Upper1(str)

Upper cases the first letter of a string.

Example:

Result:

valueOf

Usage: valueOf()

Returns the primitive value of a String instance.

Example:

Result:

FormatMiles

Usage: FormatMiles(number)

Converts number to a string like "2.34 miles".

Example:

Result:

FormatNumber

Usage: FormatNumber(number, optional precision = 0, optional useThousandsSeparator = true)

Formats number with specified precision. Default has no decimal places, e.g. "2,346"

Example:

Result:

FormatNumber2

Usage: FormatNumber2(number, optional precision = 0, optional useThousandsSeparator = true)

Formats number with 2 decimal places, e.g. "2,345.56".

Example:

Result:

FormatPercent

Usage: FormatPercent(number, optional presision = 1)

Formats number as percentage.

Example:

Result:


CategoryFunctions

Strings (last edited 2015-02-08 06:30:49 by LKD70)