Next: , Previous: Mapping Folding and Unfolding, Up: Strings


5.5.5.12 Miscellaneous String Operations
— Scheme Procedure: xsubstring s from [to [start [end]]]
— C Function: scm_xsubstring (s, from, to, start, end)

This is the extended substring procedure that implements replicated copying of a substring of some string.

s is a string, start and end are optional arguments that demarcate a substring of s, defaulting to 0 and the length of s. Replicate this substring up and down index space, in both the positive and negative directions. xsubstring returns the substring of this string beginning at index from, and ending at to, which defaults to from + (end - start).

— Scheme Procedure: string-xcopy! target tstart s sfrom [sto [start [end]]]
— C Function: scm_string_xcopy_x (target, tstart, s, sfrom, sto, start, end)

Exactly the same as xsubstring, but the extracted text is written into the string target starting at index tstart. The operation is not defined if (eq? target s) or these arguments share storage – you cannot copy a string on top of itself.

— Scheme Procedure: string-replace s1 s2 [start1 [end1 [start2 [end2]]]]
— C Function: scm_string_replace (s1, s2, start1, end1, start2, end2)

Return the string s1, but with the characters start1 ... end1 replaced by the characters start2 ... end2 from s2.

— Scheme Procedure: string-tokenize s [token_set [start [end]]]
— C Function: scm_string_tokenize (s, token_set, start, end)

Split the string s into a list of substrings, where each substring is a maximal non-empty contiguous sequence of characters from the character set token_set, which defaults to char-set:graphic. If start or end indices are provided, they restrict string-tokenize to operating on the indicated substring of s.

— Scheme Procedure: string-filter s char_pred [start [end]]
— C Function: scm_string_filter (s, char_pred, start, end)

Filter the string s, retaining only those characters which satisfy char_pred.

If char_pred is a procedure, it is applied to each character as a predicate, if it is a character, it is tested for equality and if it is a character set, it is tested for membership.

— Scheme Procedure: string-delete s char_pred [start [end]]
— C Function: scm_string_delete (s, char_pred, start, end)

Delete characters satisfying char_pred from s.

If char_pred is a procedure, it is applied to each character as a predicate, if it is a character, it is tested for equality and if it is a character set, it is tested for membership.