Skip to content

Modern String Shrink

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › String Library › String Library › Shrink

Shrink

Trims both ends and collapses each inner run of spaces to one.

Syntax

Shrink( s [, mask] )

Notes

  • O(n*k)

Examples

#import "std/strings"
using strings

dim as ustring s = ",,, one , two     three, four,"

print Shrink( s, " ," )       '' one two three four
print Shrink( "  a   b  " )   '' a b -- the default mask is a space
print Shrink( s, "" )         '' unchanged -- an empty mask has nothing to shrink

Library: String Library
Category: String Library
Documented under: The Functions

Clone this wiki locally