www.delorie.com/gnu/docs/guile/guile_466.html   search  
 
Buy GNU books!


Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

39.11.5 Selection

These procedures are called selectors, because they access information about the string or select pieces of a given string.

Additional selector procedures are documented in the Strings section (see section 21.4.5 String Selection), like string-length or string-ref.

string-copy is also available in core Guile, but this version accepts additional start/end indices.

Scheme Procedure: string-copy str [start end]
Return a freshly allocated copy of the string str. If given, start and end delimit the portion of str which is copied.

Scheme Procedure: substring/shared str start [end]
Like substring, but the result may share memory with the argument str.

Scheme Procedure: string-copy! target tstart s [start end]
Copy the sequence of characters from index range [start, end) in string s to string target, beginning at index tstart. The characters are copied left-to-right or right-to-left as needed - the copy is guaranteed to work, even if target and s are the same string. It is an error if the copy operation runs off the end of the target string.

Scheme Procedure: string-take s n
Scheme Procedure: string-take-right s n
Return the n first/last characters of s.

Scheme Procedure: string-drop s n
Scheme Procedure: string-drop-right s n
Return all but the first/last n characters of s.

Scheme Procedure: string-pad s len [chr start end]
Scheme Procedure: string-pad-right s len [chr start end]
Take that characters from start to end from the string s and return a new string, right(left)-padded by the character chr to length len. If the resulting string is longer than len, it is truncated on the right (left).

Scheme Procedure: string-trim s [char_pred start end]
Scheme Procedure: string-trim-right s [char_pred start end]
Scheme Procedure: string-trim-both s [char_pred start end]
Trim s by skipping over all characters on the left/right/both sides of the string that satisfy the parameter char_pred:

If called without a char_pred argument, all whitespace is trimmed.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003