|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
A string constant consists of a sequence of characters enclosed in either double-quote or single-quote marks. For example, both of the following expressions
represent the string whose contents are `parrot'. Strings in Octave can be of any length.
Since the single-quote mark is also used for the transpose operator (see section Arithmetic Operators) but double-quote marks have no other purpose in Octave, it is best to use double-quote marks to denote strings.
In double-quoted strings, the backslash character is used to introduce escape sequences that represent other characters. For example, `\n' embeds a newline character in a double-quoted string and `\"' embeds a double quote character.
In single-quoted strings, backslash is not a special character.
Here is an example showing the difference
toascii ("\n") ⇒ 10 toascii ('\n') ⇒ [ 92 110 ]
You may also insert a single quote character in a single-quoted string by using two single quote characters in succession. For example,
'I can''t escape' ⇒ I can't escape
Here is a table of all the escape sequences used in Octave. They are the same as those used in the C programming language.
Represents a literal backslash, `\'.
Represents a literal double-quote character, `"'.
Represents a literal single-quote character, `''.
Represents the "nul" character, control-@, ASCII code 0.
Represents the "alert" character, control-g, ASCII code 7.
Represents a backspace, control-h, ASCII code 8.
Represents a formfeed, control-l, ASCII code 12.
Represents a newline, control-j, ASCII code 10.
Represents a carriage return, control-m, ASCII code 13.
Represents a horizontal tab, control-i, ASCII code 9.
Represents a vertical tab, control-k, ASCII code 11.
Strings may be concatenated using the notation for defining matrices. For example, the expression
[ "foo" , "bar" , "baz" ]
produces the string whose contents are `foobarbaz'. See section Numeric Data Types, for more information about creating matrices.
|5.1 Creating Strings|
|5.2 Comparing Strings|
|5.3 Manipulating Strings|
|5.4 String Conversions|
|5.5 Character Class Functions|
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]|
This document was generated on December, 26 2007 using texi2html 1.76.