Skip to main content
A text string is a sequence of characters written with quotes. You can use single or double quotes, but they must always come in pairs. Quotes can also be nested, by alternating between single and double quotes.

Constructors

String()

Default constructor.

String(String)

Pass a value to copy into a new object.

String(Byte[])

Pass a byte array to build a new object.

String(Byte[], String)

Same as String(Byte[]), but also takes a code page identifier.

String(NSStream)

Pass a byte array to build a new object.

String(NSStream, String)

Same as String(NSStream), but also takes a code page identifier.

Methods

getLength()

Finds the length of a string. Returns the number of characters as an Integer.
Returns: CRMScript.Global.Integer - The number of characters in the String. Example:

toLower()

Converts the string to its lowercase representation (all lowercase).
Returns: CRMScript.Global.String - The lowercase representation of the String. Example:

toUpper()

Converts the string to its uppercase representation (all uppercase).
Returns: CRMScript.Global.String - The string in uppercase characters. Example:

isLower()

Determines if the string contains only lowercase letters. Will return true if no uppercase letters are found, otherwise false.
Returns: CRMScript.Global.Bool - True if the string contains only lowercase letters.
If any nonletters (whitespace, punctuation marks etc ) are present in the string, the method will return false!

isUpper()

Determines if the string contains only uppercase letters. Will return true if no lowercase letters are found, otherwise false.
Returns: CRMScript.Global.Bool - True if the string contains only uppercase letters.
If any nonletters (whitespace, punctuation marks etc ) are present in the string, the method will return false!

equals(String)

Compare two string a returns true if they are equal.
Returns: CRMScript.Global.Bool - True if they are equal.
Case sensitive. To ignore case, use equalsIgnoreCase() instead.
Example:

equalsIgnoreCase(String)

Same as using toLower() on both strings before calling equals().
Returns: CRMScript.Global.Bool - True if the strings are equal.
Case insensitive.
Example:

beginsWith(String)

Matching start of a string. The pattern you wish to match against must be given as an input parameter. The methods will return true if the beginning of your string matches the pattern, otherwise false.
Returns: CRMScript.Global.Bool - True if the string object begins with the string given as the parameter, taking the case into account.
Case sensitive. To ignore case, use caseBeginsWith() instead.
Example:

caseBeginsWith(String)

Matching start of a string. The pattern you wish to match against must be given as an input parameter. The methods will return true if the beginning of your string matches the pattern, otherwise false.
Returns: CRMScript.Global.Bool - True if the string object begins with the string given as the parameter, regardless of the case.
Case insensitive.

endsWith(String)

Matching end of a string. The pattern you wish to match against must be given as an input parameter. The methods will return true if the end of your string matches the pattern, otherwise false.
Returns: CRMScript.Global.Bool - True if the string object ends with the string given as the parameter taking the case into account.
Case sensitive. To ignore case, use caseEndsWith() instead.
Example:

caseEndsWith(String)

Matching end of a string. The pattern you wish to match against must be given as an input parameter. The methods will return true if the end of your string matches the pattern, otherwise false.
Returns: CRMScript.Global.Bool - True if the string object ends with the string given as the parameter regardless of case.
Case insensitive.

compare(String)

Two strings are lexicographic identical if they are the same length and they also contain the same characters in the same position.
Returns: CRMScript.Global.Integer - <0 if this is lexically smaller than the value, 0 if equal, and >0 if this is lexically larger.
Case sensitive. To ignore case, use caseCompare() instead.
Example:

caseCompare(String)

Same as applying the standard dictionary or alphabetic order.
Returns: CRMScript.Global.Integer - <0 if this is lexically smaller than the value, 0 if equal, and >0 if this is lexically larger.
Case insensitive.
Example:

append(String)

Concatenates two strings and alters the original string.
Returns: CRMScript.Global.Void
Using the append() method is currently faster than +=.
Example:

append(String)

Concatenates an ISO-8859-1 (Latin-1) character to the original string.
Returns: CRMScript.Global.Void
Using the append() method is currently faster than +=.

substitute(String, String)

Inside your string, substitute all occurrences of one substring with another.
Returns: CRMScript.Global.String - The altered string.
Text substitution works as search-and-replace and will update all occurrences.
Example:

find(String)

Finds the 1st occurrence of the substring and returns the index it starts at.
Returns: CRMScript.Global.Integer - First index of the substring.
Case sensitive, to ignore case use findCase() instead.
Example:

findCase(String)

Finds the 1st occurrence of the substring and returns the index it starts at. Returns -1 if not found.
Returns: CRMScript.Global.Integer - First index of the substring or -1.
Case insensitive.

findLast(String)

Same as find() except it will return the position of the last occurrence of the pattern.
Returns: CRMScript.Global.Integer - The position of the last occurrence of the string to match. Example:

subString(Integer, Integer)

Creates a new String of a given length. It will copy characters from the original string starting at the given position.
Returns: CRMScript.Global.String - The substring.
The position must be less than s.getLength().
Example:

until(String)

If you don’t know the exact segment length you wish to extract, one option is to copy from start until you encounter a given pattern (1st occurrence). If the pattern is not found, a copy of this original string is returned.
Returns: CRMScript.Global.String - The first part of the string. Example:

before(String)

Same usage and result as until().
Returns: CRMScript.Global.String - The part of the string preceding the search text.

beforeLast(String)

Similar to before(), but will continue copying until the last occurrence of the pattern rather than stopping at the 1st. Useful for example if you are parsing a path or URI and want everything except the document name.
Returns: CRMScript.Global.String - A string consisting of all the contents before the last needle. Example:

after(String)

Another option is to start copying after you encounter the pattern and continue extracting until you reach the end of the original string. If the pattern is not found in this, an empty string is returned.
Returns: CRMScript.Global.String - What follows the pattern.
If s is not found in this, then an empty string is returned.
Example:

afterLast(String)

Similar to after(), but will not start copying until after the last occurrence of the pattern rather than starting after the 1st.
Returns: CRMScript.Global.String - The last part of the string after the last match.

split(String)

Splits the original string in multiple segments (an array of substrings). The original string is not altered.
Returns: CRMScript.Global.String[] - Array of substrings.
You can’t split between every character (can’t use an empty string as the delimiter).The delimiter is excluded from the result.
Example:

isAlpha()

Determines if the string exclusively contains uppercase and lowercase letters. Will return true if the restriction applies, otherwise false.
Returns: CRMScript.Global.Bool - True if the string contains only alphabetic characters.
If any white-space characters are present in the string, the method will return false!
Example:

isDigit()

Determines if the string contains numeric characters [0-9] only.
Returns: CRMScript.Global.Bool - True if the string contains only numeric characters [0-9].

isAlphanumeric()

Combines the criteria of isAlpha() and isDigit(), and will return true if the string is restricted to any combination of lowercase and uppercase letters and digits [0-9].
Returns: CRMScript.Global.Bool - True if the string contains only alphabetic characters or digits.

isNull()

Returns true if the string is NULL/NUL/NIL, otherwise false. See example for isEmpty().
Returns: CRMScript.Global.Bool - True if the string is NULL/NUL/NIL.

isEmpty()

Returns true if the string is empty ("") or NULL/NUL/NIL, meaning it contains no characters.
Returns: CRMScript.Global.Bool - True if the String contains no characters. Example:

toBool()

Converts a String to its boolean representation. Returns false if the String “1” or “True”, otherwise true.
Returns: CRMScript.Global.Bool Example:

toInteger()

Converts a String to its numeric representation.
Returns: CRMScript.Global.Integer

toLong()

Converts a String to a Long.
Returns: CRMScript.Global.Long
If the number in the String is outside the bounds of a Long, it will become the highest positive or lowest negative number of a Long.

toFloat()

Converts a String to a Float.
Returns: CRMScript.Global.Float - The float value of a string. Example:

toDate()

Converts a String to a Date.
Returns: CRMScript.Global.Date - The date value of a string.

toDateTime()

Converts a String to a DateTime.
Returns: CRMScript.Global.DateTime - The DateTime value of a string.

toTime()

Converts a String to a Time object.
Returns: CRMScript.Global.Time - The time value of a string.

toByteArray()

Converts a String to an array of bytes (ISO-8859-1).
Returns: CRMScript.Global.Byte[] - An array of bytes (the string is converted to ISO-8859-1)

escape(String)

Escape special characters of a string. Special characters are given as a parameter.
Returns: CRMScript.Global.String - The escaped coded string.

extractHtmlBody(Bool)

Extracts the body content of a string containing an HTML document. If the convertBodyToDiv parameter is true, the body tag will be replaced with a div tag.
Returns: CRMScript.Global.String - The body content of a string containing an HTML document

extractHtmlHead(Bool)

Extracts the head content of a string containing an HTML document. If the stripTitle parameter is true, the title tag will be excluded.
Returns: CRMScript.Global.String - The head content of a string containing an HTML document

isHtmlDocument()

Tests if this string is an HTML document. The test is not fool-proof, but rather a simple test if the string begins with one of the standard opening tags for HTML documents.
Returns: CRMScript.Global.Bool - True if HTML-document, otherwise false.

htmlDecode()

HTML decode the string.
Returns: CRMScript.Global.String - An HTML decoded version of the String.

htmlEncode()

HTML encode the string.
Returns: CRMScript.Global.String - An HTML encoded version of the String.

getEmails()

Returns an array of the names and email addresses in a String. Format: a comma-separated list of “name”>emailAddr>
Returns: CRMScript.Native.Vector - Vector of names and emails.
If there is a malformed address in the string, the vector returned is empty.

isValidEmail()

Checks if the string is a valid email address.
Returns: CRMScript.Global.Bool - True if the string is a valid email address.

getLine()

This function will return and remove a line from this string. It is normally used to process a longer text, stored in a string, in a line-wise fashion. The newline is returned as well. If there are not any newlines, then this whole string is returned, and this string is set to empty.
Returns: CRMScript.Global.String - The first line of the string.

getWord(Integer)

Returns the word at a given position from the string.
Returns: CRMScript.Global.String - The word at the given position.
Word 0 is the first word in the string, even if it’s after some leading whitespace.
Example:

isNumber()

Returns true if it is possible to convert a string to an integer. If the string begins with a number it is possible to convert until an illegal character occurs.
Returns: CRMScript.Global.Bool - True if the string can be converted to an integer, false otherwise. Example:

urlDecode()

URL-decode the string.
Returns: CRMScript.Global.String - A URL decoded version of the String.

urlEncode()

URL-encode the string.
Returns: CRMScript.Global.String - A URL encoded version of the String.

utf8Decode()

Returns a UTF-8 decoded string, possibly containing characters outside the character space of ISO-8859-1 (Latin-1).
Returns: CRMScript.Global.String
The characters in the string are interpreted as UTF-8 and decoded. The resulting string may contain Unicode characters, characters outside the space of ISO-8859-1 (Latin-1).

utf8Encode()

The characters are coded using the UTF-8 format, and the string returned consists of only ASCII characters, encoding the Unicode characters (outside ASCII/Latin-1) in UTF-8 format.
Returns: CRMScript.Global.String - The UTF-8 representation of the string

xmlDecode()

XML decode the string.
Returns: CRMScript.Global.String - An XML decoded version of the string.

xmlEncode()

XML encode the string.
Returns: CRMScript.Global.String - An XML encoded version of the string.

keepChars(String)

Removes all characters except those listed from the string.
Returns: CRMScript.Global.String - String stripped from all other characters.

parseCSV(String)

Splits the current line separated with a delimiter.
Returns: CRMScript.Global.String[]
The delimiter must be a single character.

parseSOMultiLanguageString(Integer)

Returns the string part of the specified culture from the multi-language string. These strings are typically used in SuperOffice list and description data.
Returns: CRMScript.Global.String
Available languages: Norwegian = 0, English = 1, German = 2, Swedish = 3, Danish = 4, Dutch = 5, French = 6, Spanish = 7, Italian = 8, Czech = 9, Finnish = 10, Polish = 11

prettyChop(Integer)

This function will chop the current string after the specified number of characters and return the result. It will also append three dots at the end of the string. It will not change the current string.
Returns: CRMScript.Global.String - The chopped version of the string, including three dots at the end.

quote(String)

This function will quote the String with the quoteString. Each line of the String will start with quoteString, after calling quote.
Returns: CRMScript.Global.String

regexp(String)

Uses regexp pattern on the String object. Support for sub-expressions is also present. No matches will result in an array with length 0. res[0] will point to the entire matched string. res[1 … n-1] will point to the matches of the sub-expressions.
Returns: CRMScript.Global.String[]
The regexp is case-insensitive.
Example:

stripLeading(String)

Remove all characters given by the parameter at the beginning of the String.
Returns: CRMScript.Global.String - The string without the leading characters.

stripLeadingAndTrailing(String)

Remove all characters given by the parameter at the beginning and the end of the String.
Returns: CRMScript.Global.String - The string without the leading and trailing characters.

stripTrailing(String)

Remove all characters given by the parameter at the end of the String.
Returns: CRMScript.Global.String - The string without the trailing characters.

wrap(Integer, Bool)

This function will wrap the String in lines of wanted length
Returns: CRMScript.Global.Void