Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.
Next: String Modification, Previous: List/String Conversion, Up: Strings [Contents][Index]
Portions of strings can be extracted by these procedures.
string-ref
delivers individual characters whereas
substring
can be used to extract substrings from longer strings.
Return the number of characters in string.
Return the number of characters in str as a size_t
.
Return character k of str using zero-origin indexing. k must be a valid index of str.
Return character k of str using zero-origin indexing. k must be a valid index of str.
Return a copy of the given string str.
The returned string shares storage with str initially, but it is copied as soon as one of the two strings is modified.
Return a new string formed from the characters of str beginning with index start (inclusive) and ending with index end (exclusive). str must be a string, start and end must be exact integers satisfying:
0 <= start <= end <= (string-length str)
.
The returned string shares storage with str initially, but it is copied as soon as one of the two strings is modified.
Like substring
, but the strings continue to share their storage
even if they are modified. Thus, modifications to str show up
in the new string, and vice versa.
Like substring
, but the storage for the new string is copied
immediately.
Like substring
, but the resulting string can not be modified.
Like scm_substring
, etc. but the bounds are given as a size_t
.
Return the n first characters of s.
Return all but the first n characters of s.
Return the n last characters of s.
Return all but the last n characters of s.
Take characters start to end from the string s and either pad with chr or truncate them to give len characters.
string-pad
pads or truncates on the left, so for example
(string-pad "x" 3) ⇒ " x" (string-pad "abcde" 3) ⇒ "cde"
string-pad-right
pads or truncates on the right, so for example
(string-pad-right "x" 3) ⇒ "x " (string-pad-right "abcde" 3) ⇒ "abc"
Trim occurrences of char_pred from the ends of s.
string-trim
trims char_pred characters from the left
(start) of the string, string-trim-right
trims them from the
right (end) of the string, string-trim-both
trims from both
ends.
char_pred can be a character, a character set, or a predicate
procedure to call on each character. If char_pred is not given
the default is whitespace as per char-set:whitespace
(see Standard Character Sets).
(string-trim " x ") ⇒ "x " (string-trim-right "banana" #\a) ⇒ "banan" (string-trim-both ".,xy:;" char-set:punctuation) ⇒ "xy" (string-trim-both "xyzzy" (lambda (c) (or (eqv? c #\x) (eqv? c #\y)))) ⇒ "zz"
Next: String Modification, Previous: List/String Conversion, Up: Strings [Contents][Index]