Search                        Top                                  Index
HELP SUBSTRING                     updated Mark Rubinstein  December 1985

Accessing or updating a substring of a string or word.

    substring(<index>,<length>,<string|word>) -> <string>
    <string> -> substring(<index>,<length>,<string|word>)

Keywords: string, substring, word

This procedure takes two numbers and a string or word and returns the
sub-string of the given string starting at the position indicated by the
first integer and of length equal to the second integer, for example:

    substring(3, 4, 'elephant') =>
    ** epha

It can also access parts of words, but the result will still be a
string:

    substring(2, 3, "mammoth") =>
    ** amm

SUBSTRING has an updater.  That is, it can be used to alter the contents
of a string, e.g.:

    'the cat' -> x;
    'dog' -> substring(5, 3, x);
    x =>
    ** the dog

Note that you can't update words.  If you try, you'll get a *MISHAP.
SUBWORD is just like SUBSTRING except that it returns a word and it
has no updater.

See also: HELP
    *STRINGS            - introduction to strings
    *ISSUBSTRING        - identification of the presence of a substring
    *ISSUBSTRING_LIM    - as ISSUBSTRING, but with restricted search
    *SUBSCRS            - accessing or updating a string
    *SUBWORD            - accessing a part of a word
    REF *STRINGS,       - details on strings and string processing

--- C.all/help/substring -----------------------------------------------
--- Copyright University of Sussex 1987. All rights reserved. ----------