String

Extended supports Strings, and has some built-in functionality for String manipulation.

Strings can be written using double quotes "" or single quotes ''

"This is a string"
'This is also a string'

Escaping Characters

Escaping is the practice of using another character to ‘escape’ a character that would otherwise have a special meaning. For example a double quote " would normally signify the end of a String, but there might be circumstances where it is desirable to include the double quote as part of the string. Escaping can be done using a backlash \ prior to the character that should be escaped.

'Extended\'s functionality is great!'   \\ Extended's functionality is great!

Wildcard Character

Wildcards are special characters that can be used to match unknown characters. This is particularly useful for Querying or conditional statements where one might want to partially match text. Extended utilizes * as the wildcard character for matching any number of unknown characters. * can be used anywhere in a string - start, middle or end.

"Michael" = "*mic*"                             // True - "Michael" contains "mic"
"Michelle" = "*mic*"                            // True - "Michelle" contains "mic"
"Mikhail"  = "*mic*"                            // False - "Mikhail" does not contain "mic"
"Amicable" = "*mic*"                            // True - "Amicable" contains "mic"
"Biology" = "*ology"                            // True - "Biology" ends with "ology"
"Biological" = "*ology"                         // False - "Biological" does not end with "ology"
"Biological" = "Bio*"                           // True - "Biological" starts with "Bio"
"Biology" = "Bio*"                              // True - "Biology" starts with "Bio"

Concatenation

Concatenation allows you to join two or more strings together. This can be done using the + operator.

"We are " + "the sultans " + "of swing"                         // We are the sultans of swing

piece1 := "I must not fear. "
piece2 := "Fear is the mind-killer."

quote := piece1 + piece2
quote                                                           // I must not fear. Fear is the mind-killer.

String Comparison

Strings can be compared using the equality operator =. Normal string comparison is case sensitive, however string comparison with wildcards is case insensitive.

"Michael" = "*mic*"                     // True
"Michael" = "*michael*"         // True
"Michael" = "michael"           // False

Methods

Methods that can be chained onto strings, or string variables, to perform specific actions.

indexOf

The indexOf() method returns the index of the first ocurrence of the provided substring within the string. If the substring is not found, MISSING is returned.

Syntax

Return Value

<string>.indexOf(<substring>)

The index of the first ocurrence of substring

<string>.indexOf(<substring>, [startIndex])

The index of the first ocurrence of substring after startIndex

substring

The string to search for.

startIndex

[Optional] The index from where to start searching. Anything before it will be ignored.

Examples

modelID := "ORG007_KP005_TABL001"
undIndex := modelID.indexOf("_")
undIndex                                                    // 6
undIndex2 := modelID.indexOf("_", undIndex + 1)             // 12
orgID := modelID.substring(0, undIndex)
orgID                                                       // ORG007
kpID := modelID.substring(undIndex + 1)                     // KP005
tableID := modelID.substring(undIndex2 + 1)                 // TABL001

size

The size() method returns the length of the string.

Syntax

Return Value

<string>.size()

Number of characters

Examples

"hello".size()                                  // 5
"Corporater".size()                             // 10
"supercalafragalisticexpialadoshus".size()      // 33

strip

The strip() method can be used to remove all of the extra spaces in a string. This includes leading, trailing, and inline spaces. Inline spaces will be reduced to singular spaces, but no further than that. For example, three spaces between words would be reduced down to one space.

Syntax

Return Value

<string>.strip()

The String with extras spaces removed

Examples

myString := " There are  too    many spaces in   this string "
myString.strip()                                // "There are too many spaces in this string"

substring

The substring() method returns a fragment of the string, based on a start index and an optional end index.

Syntax

Return Value

<string>.substring(startIndex, [endIndex])

String from start index to end index

startIndex

The index of the first desired character (inclusive). Indexes start at 0 not 1.

endIndex

[Optional] The index of the character at which to stop (exclusive). If no end index is specified, substring will process from the start index to the end of the string.

Examples

"abcdefg".substring(3)          \\ defg
"abcdefg".substring(3,4)        \\ d
"abcdefg".substring(3,5)        \\ de