standard-gbbopen-instanceGBBopen Toolsundefmethodtrimmed-substringGoTo Top

trimmed-substring   character-bag string &optional start end => trimmed-substring[Function]

Extract and trim a substring from string.

Package   :gbbopen-tools

Module   :gbbopen-tools

Arguments and values

character-bag     A sequence containing characters
string     A string designator
start     Starting index into string (default is 0)
end     Ending index into string (default is nil, meaning end of string)
trimmed-substring     A string

The extracted, trimmed string


  > (trimmed-substring '(#\space #\tab) "xxx   abc   yyy" 3 12)
  > (trimmed-substring " " "xxx   abc   yyy" 3 12)
  > (trimmed-substring " " "xxx   abc   yyy" 3)
  "abc   yyy"
  > (trimmed-substring " " "xxx   abc   yyy" 3 13)
  "abc   y"
  > (trimmed-substring " " "xxx   abc   yyy" 2 12)
  "x   abc"
  > (trimmed-substring " " "   abc   ")

The function trimmed-substring is semantically equivalent to

  (string-trim character-bag (subseq string start end))
but avoids allocating an intermediate substring.

The GBBopen Project

standard-gbbopen-instanceGBBopen Toolsundefmethodtrimmed-substringGoTo Top