Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
The string type holds character-string values, used to represent and manipulate text.
You create string constants by enclosing text within either single (') or double (") quotes.
Glish treats text within single quotes as a single string value; these constants are scalars. For example,
'hello there'yields a string value of one element. That element has 11 characters.
Glish breaks up text within double quotes into words at each block of whitespace (blanks, tabs, or newlines). The whitespace is removed from the result. Thus
"hello there"yields a two-element string value. The first element is the character string hello and the second element the string there. Leading and trailing whitespace is ignored, so
" hello there "is equivalent to
"hello there"
In both kinds of string constants, a backslash character (\
)
introduces an escape sequence. Except for the standard
escape sequences (see Table 4.2, page ), any other character
following a backslash, ``\
'', is passed along literally.
For example,
"hello \"there\" how \ are\nyou?"yields the string
hello "there" how are you?whose length is 5 (recall that the
\n
newline is treated as
whitespace and removed from the string), while
'hello \'there\' how \ are\nyou?'yields the single-element string
hello 'there' how are you?
There are a number of options available for manipulating strings: