A lexical string constant enclosed in double quotes evaluates to a value
of type string. A string consists of a sequence of characters. The
number of characters in a string is called its length. The empty string,
denoted by "", contains no characters and has a length of zero. There is
no limit to the string size. Strings may be wrap across several lines in
MN8 programs. Strings may also contain the escape sequences defined in
Escape Sequences. Note that escape sequences are not expanded in strings
that are written with the back-quote character.
String Expressions
Expression Value Value Type
----------- ------- ----------
"abc" "abc" String
`ab\nc` "ab\nc" String
"abc" + 'd' "abcd" String
"abc".length 3 Integer
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
Parameters: |
$value : | To this will be compared this concept. |
|
Returns true if this concept and the concept given as parameter is
equal, false otherwise.
Parameters: |
$index : | The index of the character. |
|
Returns the character at the specified index.
$str = "This is a test."
print $str.charAt(3)
-- the result is --
i
Parameters: |
$value : | The string to be compared. |
|
The value 0 if the argument string is equal to this string; a value less
than 0 if this string is lexicographically less than the string argument
and a value greater than 0 if this string is lexicographically greater
than the string argument.
$str = "This is a test."
print $str.compareTo("This is a text.")
-- the result is --
-5
Parameters: |
$expr : | The expression to be applied to this concept. |
|
Returns true if the specified expression match this concept, false
otherwise.
$str = "This is a test."
print $str.contains(Simplex.create("*s"))
-- the result is --
true
Parameters: |
$value : | String to be searched in this concept. |
|
Returns true if the specified string is found in this concept, false
otherwise.
$str = "This is a test."
print $str.contains("is")
-- the result is --
true
Returns true if the character sequence represented by the parameter is a
suffix of the character sequence represented by this concept, false
otherwise.
$str = "This is a test."
print $str.endsWith("st.")
-- the result is --
true
Parameters: |
$value : | The string to compare this concept against. |
|
Returns true if the parameter and this concept are equal, ignoring case,
false otherwise.
$str = "This is a test."
print $str.equalsIgnoreCase("tHiS iS a TesT.")
-- the result is --
true
Returns a integer concept representing this concept length.
$str = "This is a test."
print $str.getLength
-- the result is --
15
Returnes a series with lines from this concept. Where the "\n" character
is found there begins the new line. If not found any "\n" character then
the returned series will contain a single element which represents this
concept.
$str = "This is\n a test."
print $str.getLines
-- the result is --
This is
a test.
Returns a series which contains the tokens of this concept, tokenized by
the specified delimiter. Delimiter will not be treated as token.
$str = "This is a test."
print $str.getTokens(" ")
-- the result is --
This
is
a
test.
Returns a series which contains the tokens of this concept, tokenized by
the specified delimiter, the delimiter is returned as a token.
$str = "This is a test."
print $str.getTokensWithDelimiters(" ")
-- the result is --
This
is
a
test.
If the string argument occurs as a substring within this concept, then
the index of the first character of the first such substring is returned
if it does not occur as a substring, -1 is returned.
$str = "This is a test."
print $str.indexOf("is")
-- the result is --
3
Parameters: |
$value : | Any string. |
$index : | The index to start the search from. |
|
If the string argument occurs as a substring within this object and the
starting index no smaller than fromIndex, then the index of the first
character of the first such substring is returned. If it does not occur
as a substring starting at fromIndex or beyond, -1 is returned.
$str = "This is a test."
print $str.indexOf("is", 4)
-- the result is --
6
If the string argument occurs one or more times as a substring within
this concept, then the index of the first character of the last such
substring is returned. If it does not occur as a substring, -1 is
returned.
$str = "This is a test."
print $str.lastIndexOf("is")
-- the result is --
6
Parameters: |
$valiue : | Any string. |
$index : | The index to start the search from. |
|
If the string argument occurs one or more times as a substring within
this concept at a starting index no greater than fromIndex, then the
index of the first character of the last such substring is returned. If
it does not occur as a substring starting at fromIndex or earlier, -1 is
returned.
$str = "This is a test."
print $str.lastIndexOf("is", 4)
-- the result is --
3
Parameters: |
$expr : | The expression to be applied to this concept. |
|
Returns true if the specified expression match this concept, false
otherwise.
$str = "This is a test."
print $str.matches(Simplex.create("*is*"))
-- the result is --
true
Parameters: |
$oldChar : | The oldChar to be replaced. |
$newChar : | The newChar with which will be replaced. |
|
If the character oldChar does not occur in the character sequence
represented by this concept, then a reference to this concept is
returned. Otherwise, a new string concept is created that represents a
character sequence identical to the character sequence represented by
this string concept, except that every occurrence of oldChar is replaced
by an occurrence of newChar.
$str = "This is a test."
print $str.replace('s', 'x')
-- the result is --
Thix ix a text.
Parameters: |
$expr : | The expression to be applied to this concept. |
|
Select that portion from this concept which match the specified
expression.
$str = "This is a test."
print $str.select(Simplex.create("*s"))
-- the result is --
This
is
Returns true if the character sequence represented by the argument is a
prefix of the character sequence represented by this string concept,
false otherwise.
$str = "This is the test."
print $str.endsWith("th")
-- the result is --
true
Parameters: |
$value : | The prefix. |
$index : | From where to begin looking in the string. |
|
Returns true if the character sequence represented by the argument is a
prefix of the substring of this object starting at index given as
parameter, false otherwise.
$str = "This is the test."
print $str.startsWith("th", 9)
-- the result is --
true
Parameters: |
$index : | The begining index, inclusive. |
$length : | The ending index, exclusive. |
|
Returns a new string concept that is a substring of this string concept.
The substring begins at the specified beginIndex and extends to the
character at index endIndex - 1. Thus the length of the substring is
endIndex-beginIndex.
$str = "This is a test."
print $str.substring(6, 10)
-- the result is --
is a
Parameters: |
$index : | The begining index, inclusive. |
|
Returns a new string concept that is a substring of this string concept.
The substring begins with the character at the specified index and
extends to the end of this string.
$str = "This is a test."
print $str.substring(9)
-- the result is --
a test.
Converts all of the characters in this string concept to lower case and
returns the resulted string concept.
$str = "ThIs iS a TeSt."
print $str.toLowerCase
-- the result is --
this is a test.
Returns a new string concept which is represents this concept.
$str = "This is a test."
print $str.toStringConcept
-- the result is --
This is a test.
Converts all of the characters in this string concept to upper case and
returns the resulted string concept.
$str = "ThIs iS a TeSt."
print $str.toUpperCase
-- the result is --
THIS IS A TEST.
Removes white space from both ends of this string.
$str = " This is a test. "
print $str.trim
-- the result is --
This is a test.
Parameters: |
$value : | Number of columns |
|
Returns a new string concept representing this concept wrapped to the
given column number and aligned to left by default.
$str = "This is a test."
print $str.wrap(5)
-- the result is --
This
is a
test.
Parameters: |
$value : | Number of columns |
$align : | Alignment (ex. left, right, center) |
|
Returns a new string concept representing this concept wrapped to the
given column number and aligned as it is specified.
$str = "This is a test string to verify the wrap method in this concept."
print $str.wrap(10, "center")
-- the result is --
This is a
test string
to verify
the wrap
method in
this
concept.
Returns a new string concept representing this concept wrapped to 72
column and aligned to left by default.
$str = "This is a test string to verify the wrap method in this concept. This must return a string concept with 72 column and aligned to left. Let's test it."
print $str.wrap
-- the result is --
This is a test string to verify the wrap method in this concept. This
must return a string concept with 72 column and aligned to left. Let's
test it.