str Module

%

% interpolate

See interpolate.

=~

=~ regex

See regex.

capitalize

'sym string

Returns a copy of 'sym with the first character capitalized.

indent

'sym int string

Returns string containing 'sym indented with int spaces.

indexof

string1 string2 int

If string2 is contained in string1, returns the index of the first match or -1 if no match is found.

interpolate

string quot string

Substitutes the placeholders included in string with the values in quot.

Note

If quot contains symbols or quotations, they are not interpreted. To do so, call apply before interpolating.

join

quot 'sym string

Joins the elements of quot using separator 'sym, producing string.

length

'sym int

Returns the length of 'sym.

lowercase

'sym string

Returns a copy of 'sym converted to lowercase.

match

string1 string2 bool

Returns true if string2 matches string1, false otherwise.

Tip

string2 can be a sgregex.-compatible regular expression.

repeat

'sym int string

Returns string containing 'sym repeated int times.

replace

string1 string2 string3 string4

Returns a copy of string1 containing all occurrences of string2 replaced by string3

Tip

string2 can be a sgregex.-compatible regular expression.

regex

string1 string2 quot

Performs a search and/or a search-and-replace operation using pattern string2.

string2 can be one of the following patterns:

  • /search-regex/modifiers
  • s/search-regex/replacemenet/modifiers

quot is always a quotation containing:

  • One or more strings containing the first match and captures (if any), like for the search operator.
  • A string containing the resuling string after the search-and-replace operation.

Tip

  • search-regex can be a sgregex.-compatible regular expression.
  • modifiers are optionals can contain one or more of the following characters, in any order:
    • i: case-insensitive match.
    • m: multi-line match.
    • s: dot character includes newlines.

search

string1 string2 quot

Returns a quotation containing the first occurrence of string2 within string2. Note that:

  • The first element of quot is the matching substring.
  • Other elements (if any) contain captured substrings.

Tip

string2 can be a sgregex.-compatible regular expression.

split

'sym1 'sym2 quot

Splits 'sym1 using separator 'sym2 and returns the resulting strings within the quotation quot.

strip

'sym string

Returns string, which is set to 'sym with leading and trailing spaces removed.

substr

string1 int1 int2 string2

Returns a substring string2 obtained by retriving int2 characters starting from index int1 within string1.

titleize

'sym string

Returns a copy of 'sym in which the first character of each word is capitalized.

uppercase

'sym1 'sym2

Returns a copy of 'sym converted to uppercase.