str Module

%

% interpolate

See interpolate.

=%

=% apply-interpolate

See apply-interpolate.

=~

=~ regex

See regex.

apply-interpolate

string quot string

The same as pushing apply and then interpolate on the stack.

capitalize

'sym string

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

chr

int string

Returns the single character string obtained by interpreting int as an ASCII code.

escape

'sym string

Returns a copy of 'sym with quotes and backslashes escaped with a backslash.

from-semver

string dict

Given a basic SemVer-compliant string (with no additional labels) string, it pushes a dictionary dict on the stack containing a major, minor, and patch key/value pairs.

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.

Notes

  • If quot contains symbols or quotations, they are not interpreted. To do so, call apply before interpolating or use apply-interpolate instead.
  • You can use the $# placeholder to indicate the next placeholder that has not been already referenced in the string.
  • You can use named placeholders like $pwd, but in this case quot must contain a quotation containing both the placeholder names (odd items) and the values (even items).

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.

ord

string int

Returns the ASCII code int corresponding to the single character string.

parse-url

string url

Parses the url string into its components and stores them into url.

prefix

'sym1 'sym2 string

Prepends 'sym2 to 'sym1.

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.

semver-inc-major

string1 string2

Increments the major digit of the SemVer-compliant string (with no additional labels) string1.

semver-inc-minor

string1 string2

Increments the minor digit of the SemVer-compliant string (with no additional labels) string1.

semver-inc-patch

string1 string2

Increments the patch digit of the SemVer-compliant string (with no additional labels) string1.

semver?

string bool

Checks whether string is a SemVer-compliant version or not.

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.

suffix

'sym1 'sym2 string

Appends 'sym2 to 'sym1.

titleize

'sym string

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

to-semver

dict string

Given a a dictionary dict containing a major, minor, and patch key/value pairs , it pushes a basic SemVer-compliant string (with no additional labels) string on the stack.

uppercase

'sym1 'sym2

Returns a copy of 'sym converted to uppercase.