String Summary The wrapper class for the string primitive type. Description The System.String class represents sequences of characters, known as "strings". The System.String class is the wrapper class for the string primitive type. All string literals are implemented as instances of the System.String class. Differences to JavaScript match() will never return null. If there are no matches, an empty array is returned. JS++ does not implement a String.substr() method because it causes confusion with String.substring(). Instead, String.substringFor() is the JS++ equivalent of the JavaScript String.prototype.substr() localeCompare() is not implemented. Use Externals.JS.String.prototype.localeCompare instead. search() is not implemented. It's just indexOf() using regular expressions, so indexOf() has been overloaded to take a regex. Examples Instantiation 123import System; System.String str = new System.String("abc"); Auto-boxing 123import System; System.String str = "abc"; Primitives Only 1string str = "abc"; Methods appendInserts the specified text at the end of the string. betweenMatches all substrings between two delimiters. charAtExtracts the character from a given position in the string. charCodeAtGets the Unicode value of a character at a given position. compactRemoves all whitespace from the string. compareCompares the String object to another String object. concatConcatenates two strings together. containsChecks if the string contains the specified substring. countCounts the occurrences of the specified substring in the string. countLinesCounts the number of lines in the string (including empty lines). countNonEmptyLinesCounts the number of non-empty lines in the string. EMPTYA constant field that represents an empty string. endsWithChecks if the string ends with the specified substring. escapeEscapes JS++ escape sequences with a preceding backslash. escapeQuotesEscapes all double and single quotes. formatReplaces formatting sequence(s) with their corresponding argument(s). fromCharArrayConstructs a new string from an array of character values. fromCharCodeReturns a string based on a sequence of Unicode values. icontainsChecks if the string contains the specified substring by performing a case-insensitive search. icountCounts the occurrences of the specified substring in the string while ignoring case. indexOfGets the first position a substring occurs at or regular expression matches at. insertInserts a substring at the specified position in the string. isEmptyChecks if the string contains no characters. isLowerCaseChecks if the alphabetical characters in the string are lowercase letters. isUpperCaseChecks if the alphabetical characters in the string are uppercase letters. isWhitespaceChecks if the string is composed entirely of whitespace characters. joinLinesCondenses multiple lines of text into a single line. joinNonEmptyLinesCondenses multiple non-empty lines of text into a single line of text. lastIndexOfGets the last position a substring occurs at or regular expression matches at. lengthReturns the number of characters in the string. matchFinds a substring or matches for a regular expression. padLeftPads the string with spaces from the left until it reaches the specified width (number of characters). padRightPads the string with spaces from the right until it reaches the specified width (number of characters). prependInserts the specified text to the beginning of the string. quoteWraps the string in double quotes. quoteSingleWraps the string in single quotes. repeatRepeats the string the specified number of times. replacePerforms a regular expression search over the string and replaces the matched pattern(s) with the specified replacement string. reverseReverses the string. sliceExtracts a substring from the given position(s). splitDivides the string into substrings, optionally separated by a delimiter. splitLinesSplits the string into individual lines and returns the resulting lines in an array. startsWithChecks if the string begins with the specified substring. String (Constructor)Constructs a System.String object. substringExtracts a substring. substringForExtract a substring for a specified number of characters. toCharArrayConstructs a character array from the string value. toExternalConverts the string value to its equivalent external value. tokenGets the token at the specified index. toLowerCaseConverts each character of the string to lowercase. toStringReturns the string value. toUpperCaseConverts each character of the string to uppercase. trimRemoves whitespace from the beginning and end of the string. trimLeftRemoves whitespace from the beginning of the string. trimMultiRemoves whitespace from thje beginning and end of each line of the string. trimMultiLeftRemoves leading whitespace from the beginning of each line of the string without removing newline characters. trimMultiRightRemoves trailing whitespace from the end of each line of the string without removing newline characters. trimRightRemoves whitespace from the end of the string. truncateCuts off the string at the specified length (number of characters). unescapeRemoves prefixed backslashes to produce equivalent escape sequences from the result. unescapeQuotesRemoves the leading backslash from all escaped double and single quotes. unquoteRemoves quotation marks (double and single). valueOfReturns the primitive string value wrapped by the System.String object. Share HTML | BBCode | Direct Link