GNU Info

Info Node: (elisp)Modifying Strings

(elisp)Modifying Strings


Next: Text Comparison Prev: Creating Strings Up: Strings and Characters
Enter node , (file) or (file)node

Modifying Strings
=================

   The most basic way to alter the contents of an existing string is
with `aset' (Note: Array Functions).  `(aset STRING IDX CHAR)' stores
CHAR into STRING at index IDX.  Each character occupies one or more
bytes, and if CHAR needs a different number of bytes from the character
already present at that index, `aset' signals an error.

   A more powerful function is `store-substring':

 - Function: store-substring string idx obj
     This function alters part of the contents of the string STRING, by
     storing OBJ starting at index IDX.  The argument OBJ may be either
     a character or a (smaller) string.

     Since it is impossible to change the length of an existing string,
     it is an error if OBJ doesn't fit within STRING's actual length,
     or if any new character requires a different number of bytes from
     the character currently present at that point in STRING.


automatically generated by info2www version 1.2.2.9