String utilities (#29)

For a complete description of a given verb, do `help $string_utils:verbname'

Conversion routines:

:from_list (list [,sep]) => "foo1foo2foo3"
:english_list (str-list[,none-str[,and-str[, sep]]]) => "foo1, foo2, and foo3"
:title_list*c (obj-list[,none-str[,and-str[, sep]]]) => "foo1, foo2, and foo3"
or => "Foo1, foo2, and foo3"
:from_value (value [,quoteflag [,maxlistdepth]]) => "{foo1, foo2, foo3}"

:to_value (string) => {success?, value or error message}
<img src=">refix_to_value(string) => {rest of string, value} or {0, error message}

:english_number(42) => "forty-two"
:english_ordinal(42) => "forty-second"
:ordinal(42) => "42nd"
:group_number(42135 [,sep]) => "42,135"

Type checking:

:is_numeric (string) => return true if string is composed entirely of digits


:explode (string,char) -- string => list of words delimited by char
:words (string) -- string => list of words (as with command line parser)
:word_start (string) -- string => list of start-end pairs.


:match_string (string, pattern, options) => * wildcard matching
:find_prefix (prefix, string-list)=>list index of element starting with prefix
:index_delimited(string,target[,case]) =>index of delimited string occurrence
:match (string, [obj-list, prop-name]+) => matching object
:match_player (string-list[,me-object]) => list of matching players
:match_object (string, location) => default object match...
:literal_object (string) => match against #xxx, $foo
:match_stringlist (string, targets) => match against static strings
:match_string (string, wildcard target) => match against a wildcard

Pretty printing:

:space (n/string[,filler]) => n spaces
:left (string,width[,filler]) => left justified string in field
:right (string,width[,filler]) => right justified string in field
:center/re (string,width[,filler]) => centered string in field
:columnize/se (list,n[,width]) => list of strings in n columns


:substitute (string,subst_list [,case]) -- general substitutions.
<img src=">ronoun_sub (string/list[,who[,thing[,location]]])
-- pronoun substitutions.
<img src=">ronoun_sub_secure (string[,who[,thing[,location]]],default)
-- substitute and check for names.
<img src=">ronoun_quote (string/list/subst_list) -- quoting for pronoun substitutions.

Miscellaneous string munging:

:trim (string) => string with outside whitespace removed.
:triml (string) => string with leading whitespace removed.
:trimr (string) => string with trailing whitespace removed.
:strip_chars (string,chars) => string with all chars in `chars' removed.
:strip_all_but(string,chars) => string with all chars not in `chars' removed.
:capitalize/se(string) => string with first letter capitalized.
:uppercase/lowercase(string) => string with all letters upper or lowercase.
:names_of (list of OBJ) => string with names and object numbers of items.
:nn (OBJ) => string with name and number of object.
:a_or_an (word) => "a" or "an" as appropriate for that word.
:char_list (string) => list of characters in string, with repeats.

Some useful properties:
.ascii => " !"#$%&'()*+,-./0123456789:;<=>?@ABC...
.alphabet => "abcdefghijklmnopqrstuvwxyz"

You are not logged in.

[home | help | who | search | setup | code]