Texts (character strings)
Texts (which are not really "mathematical objects", but useful to the programmer) in MuPAD® are of domain type DOM_STRING.
MuPAD can manipulate texts (strings of characters). These are primarily used for output and data input.
As far as op is concerned, a string cannot be dissected:
s := "this is a string": op(s, 1), op(s, 2)
To access individual characters or substrings, use indexed access:
Assigning to a substring may change the length of a string:
s[6..7] := "changes"; s
Using a string as a function returns the string unchanged. The arguments are not evaluated.
Strings can be concatenated using the dot operator or its functional equivalent, _concat.
The length of a string can be obtained using length.
Substrings and individual characters (which are strings of length 1) can be accessed using substring or indexed access, with indices starting at 1 and negative indices counting from the end of the string: s, s[3..-2]. It is also possible to perform an indexed assignment to a string, cf. Example 1.
To convert a string into the MuPAD expression that would be obtained by using the string as an input, use text2expr. For simple MuPAD expressions, it is possible to get a string that evaluates to that expression using expr2text. Expressions that are not convertible in this way include all expressions containing local variables set with option escape. Also, expressions involving floating point numbers usually will change when being converted to strings and back.
The output form of strings is very similar to their input form. When typesetting, spaces at the beginning and the end of strings are ignored and multiple adjacent blanks as well as newlines are collapsed to a single space.
A string is created by enclosing characters in a pair of typewriter quotes: "this is a string". The following special sequences are supported (but see below for the typeset output; these are useful only for non-typeset output):
"\n" denotes an end-of-line character.
"\b" is almost identical to "\n", except that for "pretty-printing" it encodes the baseline of the current object.
"\t" is a tabulator.
"\\" encodes a backslash.
See the documentation of print for details.