Strings

A string is a sequence of characters (letters, numerical digits, punctuation marks, whitespace, and control characters).

Parsing


strCmp

Compares %one and %two in lexicographical order with case-sensitivity.

==> strCmp("Blockland", "Blockland");
0
==> strCmp("Blockland", "Brickland"); // 'l' < 'r'
-1
==> strCmp("Blockland", "Badspot"); // 'l' > 'a'
1

striCmp

Functions the same way as strCmp, but instead compares %one and %two in lexicographical order without case-sensitivity.

strPos

Searches for the position of the character(s) %needle in the string, %hay, with case-sensitivity.

==> strPos("Test", "t");
3

striPos

Searches for the position of the character(s) %needle in the string, %hay, without case-sensitivity.

==> striPos("Test", "t");
0

strLen

Counts the total number of characters in %string.

==> strLen("Example");
7

getCharCount

Counts the number of times the character %char appears in %string.

==> getCharCount("example", "e");
2

Processing


strChr

Extracts the characters following the first instance of %char in %string, including the %char itself.

==> strChr("Hello World!", "W");
"World!"

getSubStr

Extracts characters in %string, starting at the index, %start, and ending after %numChars have been read.

==> getSubStr("Hello World!", 0, 5);
"Hello"

strReplace

Replaces all instances of %from in %source with %to.

==> strReplace("Blockhead built a town", "town", "castle");
"Blockhead built a castle"

stripChars

Removes all instances of %chars from %string.

==> stripChars("a1b2c3d4", "1234");
"abcd"

stripMLControlChars

Removes all instances of Torque Markup Language characters from %string.

stripTrailingSpaces

Removes all spaces following the last non-space character in %string

==> stripTrailingSpaces("Blockland  ");
"Blockland"

ltrim

Removes all whitespace located before the first non-whitespace character in %string

==> ltrim("    1234");
"1234"

rtrim

Removes all whitespace located after the last non-whitespace character in %string

==> rtrim("1234    ");
"1234"

trim

Removes all whitespace located before and after the first and last non-whitespace character in %string

==> trim("    1234    ");
"1234"

strUrp

Converts all lowercase alphabetical characters in %string to their uppercase equivalents.

==> strUrp("the quick brown fox jumps over the lazy dog");
"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"

strLwr

Converts all uppercase alphabetical characters in %string to their lowercase equivalents.

==> strLwr("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG");
"the quick brown fox jumps over the lazy dog"

expandEscape

Adds another escape level to escape characters.

==> expandEscape("Test\n");
"Test\\n"

collapseEscape

Removes an escape level from the escaped escape characters.

==> collapseEscape("Test\\n");
"Test\n"

deTag

Converts a tagged string to a normal string.

==> deTag('leet');
"leet"

Note: You can only detag a string that has already been transmitted to you.

getTag

Gets the tagged number associated with a tagged string

==> getTag('leet');
<somenumber>

Words


getWordCount

Counts the number of words that appear in the string %text.

==> getWordCount("Hello World");
2

getWord

Captures the word in %string located at the integer index %index.

==> getWord("Hello World", 0);
"Hello"

getWords

Captures the word(s) in %string located at the integer index %index, and optionally ending at the integer index %endIndex.

==> getWords("Hello World, how are you?", 2, 4);
"how are you?"

setWord

Replaces the word in %string located at the integer index %index with the string, %replace.

==> setWord("Hello World", "Hello", "Hey");
"Hey World"

removeWord

Removes the word in %string located at the integer index %index.

==> removeWord("Hello World", "Hello");
"World"

firstWord

Captures the first word that appears in %text.

==> firstWord("Hello World");
"Hello"

restWords

Captures every word in %text except the first.

==> restWords("Hello World, how are you?");
"World, how are you?"

Fields


'^' characters represent field delimiters.

getFieldCount

Counts the number of fields that appear in the string %text.

==> getFieldCount("Foo^Bar");
2

getField

Captures the field in %string located at the integer index %index.

==> getField("Foo^Bar", 0);
"Foo"

getFields

Captures the field(s) in %string located at the integer index %index, and optionally ending at the integer index %endIndex.

==> getFields("Foo^Bar^Baz^Qux", 2, 3);
"Baz^Qux"

setField

Replaces the field in %string located at the integer index %index with the string, %replace.

==> setField("Foo^Bar^Baz^Qux", 0, "Hello");
"Hello^Foo^Baz^Qux"

removeField

Removes the field in %string located at the integer index %index.

==> removeField("Foo^Bar^Baz^Qux", 3);
"Foo^Bar^Baz"

firstField

Captures the first field that appears in %text.

==> firstField("Foo^Bar^Baz^Qux");
"Foo"

restFields

Captures every field in %text except the first.

==> restFields("Foo^Bar^Baz^Qux");
"Bar^Baz^Qux"