Documentation for Module: strings.r ||  Module Index

syntax: !overview string functions. Modify, printing of strings.
author: Tim Johnson tim@akwebsoft.com
Note: many functions can operate on strings or blocks. Some arbitrary
choices have been made here.

Global Index
cap is-mysql overwrite randAlphaNum sql-quote
capitalize keep overwrites random-string strip
chomp keep-some pad remove-all strs
chompw left parse-float rephrase substr
columnize lfill parse-int requote substrings
copy-to make-nested parse-on rfill take
count-leading make-words parse-set Right to-title
cut make-words pick sift truncate
end? max-words picks slices un-esc
esc msg-box print-to split un-esc-blk
fill mult printf split-on unform
find-any mysql-clean prinx splitc word-wrap
front? nbsp pull-some splits zfill
invalid-mysql nnl      

Global function documentation

Function: capTopGlobals IndexNext
    syntax: cap <str-str> Capitalize the first letters of a string.
Function: capitalizeTopGlobals IndexBackNext
    syntax: capitalize <str-block-str>
    description: Capitalize a word or a block of words
    Refinement: (title) First force to lowercase
Function: chompTopGlobals IndexBackNext
    syntax: chomp <str> <str-substr> Remove a substring.
    Refinement: /right - Remove at beginning
    Refinement: /left - Remove at end
    Refinement: /first - Remove first occurrence only
    Refinement: /last - Remove last occurrence only
    Refinement: /all - Remove all occurrences only
Function: chompwTopGlobals IndexBackNext
    syntax: chompw <str-src> <str-target>
    description: Remove a substring if found based on first character.
    FirstChar: "^^" remove from front "$" - from tail "*" from any position
Function: columnizeTopGlobals IndexBackNext
    syntax: columnize <block> <int-cols> Pretty-print a block of strings on even columns.
    refinement: /with <sep> Customize seperator.
Function: copy-toTopGlobals IndexBackNext
    syntax: copy-to <str> <marker> Copy a string to a marker
Function: count-leadingTopGlobals IndexBackNext
    syntax: count-leading <string> <chars>
    description: Count matches of chars in string until match fails.
Function: cutTopGlobals IndexBackNext
    syntax: cut <block-or-string> <int-pos>
    description: Remove and return value(s) from inside of series
    Refinement: /part <int-partial> override default of 1
    Arg: pos - From where to remove.
Function: end?TopGlobals IndexBackNext
    syntax: end? <string> <sub-string> - Test for location of sub at end of str
Function: escTopGlobals IndexBackNext
    syntax: esc <any-type> If string, escape mysql special chars.
Function: fillTopGlobals IndexBackNext
    syntax: fill <string> <int-width> <str-char> <login-left-or-right>
    description: Pad string with chars on the left or right, to fill a field
       to the specified width. The string is never truncated.
Function: find-anyTopGlobals IndexBackNext
    syntax: find-any <string> <block-of-substrings>
    description: Search string for all occurences of substrings in second block
    return: Block of matches
Function: front?TopGlobals IndexBackNext
    syntax: front? <string> <sub-string> - Test for location of sub at start of str
Function: invalid-mysqlTopGlobals IndexBackNext
    syntax: invalid-mysql <str-str>
    description: Test a string to see if it a valid mysql name.
    Return none if valid, unacceptable characters if invalid.
Function: is-mysqlTopGlobals IndexBackNext
    syntax: is-mysql <str-str>
    description: Test a string to see if it a valid mysql name. Raise exception if invalid
Function: keepTopGlobals IndexBackNext
    syntax: keep <string> <str-char-start> <str-char-stop>
    description: Returns block of strings found between start and stop delimiters.
    All else is discarded
    refinement: /with Substrings found are rejoined with start and stop.
    refinement: /extra <str-addition> For each substring, add an additional string.
    example: keep "name (not here) tim" "(" ")" =>
["not here"]
    example: keep/with "name (not here) tim" "(" ")" =>
["(not here)"]
    example: keep/with/extra "name (not here) tim" "(" ")" "**" =>
["(not here)" "**"]
Function: keep-someTopGlobals IndexBackNext
    syntax: keep-some <string> <string-wanted>
    description: Remove all characters not in wanted from string
Function: leftTopGlobals IndexBackNext
    syntax: left <S-series> <int-len>
    description: Return first part of series. Determined by len.
Function: lfillTopGlobals IndexBackNext
    syntax: lfill <string> <chars> Pad string S with chars on the left,
      to fill a field to the specified width. Do not truncate.
Function: make-nestedTopGlobals IndexBackNext
    syntax: make-nested <int-size-of-outer-block> <int-size-inner-blocks>
    description: Initialize a series of nested blocks.
Function: make-wordsTopGlobals IndexBackNext
    syntax: make-words <str> Returns block delimited by whitespace in str.
    note: Retains imbedded quotation marks.
    syntax: make-words <string> Parses string on white-space, retains quotation marks.
Function: make-wordsTopGlobals IndexBackNext
    syntax: make-words <str> Returns block delimited by whitespace in str.
    note: Retains imbedded quotation marks.
    syntax: make-words <string> Parses string on white-space, retains quotation marks.
Function: max-wordsTopGlobals IndexBackNext
    syntax: max-words <string> <int-max-word>
    Description: Limits a string to max number of words
Function: msg-boxTopGlobals IndexBackNext
    syntax: msg-box <str-msg> <str-boundary> <str-delim>
    description: Create a boxed message for a console session.
    example: msg-box "hello" "-" "*"
    "---------"
    "* hello *"
    "---------"
Function: multTopGlobals IndexBackNext
    syntax: mult <series> <int> Multiply (duplicate) a series by an integer
    example: mult ["*"] 8 => ["*" "*" "*" "*" "*" "*" "*" "*"]
Function: mysql-cleanTopGlobals IndexBackNext
    syntax: mysql-clean <str-str>
    description: remove from str any characters considered illegal by mysql
Function: nbspTopGlobals IndexBackNext
    syntax: nbsp <int-n> returns string with n number of non-breaking spaces.
Function: nnlTopGlobals IndexBackNext
    syntax: nnl <string> Remove newline at end of string.
Function: overwriteTopGlobals IndexBackNext
    syntax: overwrite <string> <string-subs> <int-start>
    description: Overwrite target with subs, beginning at start.
    Note: start cannot be past the end of target.
Function: overwritesTopGlobals IndexBackNext
    syntax: overwrites do overwrite multiple times.
Function: padTopGlobals IndexBackNext
    syntax: pad <int-size> <char-str-val> Create string initalized to same chars or strings.
Function: parse-floatTopGlobals IndexBackNext
    syntax: parse-float <string> Find the first float in a string.
    refinement: /signed accept a minus
Function: parse-intTopGlobals IndexBackNext
    syntax: parse-int <string> Find the first integer in a string.
    refinement: /signed accept a minus
Function: parse-onTopGlobals IndexBackNext
    syntax: parse-on <string> <tag-or-string-start> <tag-or-string-stop>
    description: Parses a string delimited by start and stop.
      Output is series of blocks each consisting of two elements.
      Element/1 is a marker - default is is 1 or none.
      Element/2 is a substring. Substrings bounded by start and stop are proceeded
      by 1, substrings not bounded are proceeded by none.
      refinement: /with <any-type-for-bound> <any-type-for-unbound>
      Custom boundaries.
    example: parse-on "Hello: <code>print 4 - 3</code> " <code> </code>
    output: ==>> [[none "Hello: "] [1 "print 4 - 3"]]
    Blocks beginning can be evaluated as in if 1 = blk/1[do next blk]
Function: parse-setTopGlobals IndexBackNext
    syntax: parse-set <string> <str-chars>
    description: Parse the first set of characters from a string.
      Begin with first match. Stop when no match
Function: pickTopGlobals IndexBackNext
    syntax: pick <series> <int-index> Rewrite of native pick
    description: Returns the value at the specified position in a series.
    Note: Negative index references from end.
    example: pick [1 2 3] -1 => 3
Function: picksTopGlobals IndexBackNext
    syntax: picks <series> <block-of-indexes>
    description: Returns the values at the specified positions in the series.
Function: print-toTopGlobals IndexBackNext
    syntax: print-to <str> <str-marker>
    Refinement: (port) option port to write to
Function: printfTopGlobals IndexBackNext
    syntax: printf <str> <blk-subs>
    Refinement: (/with) <str-token>
    Description: Replace all occurances of <token> with first member of reference to <subs>.
    Increment subs index after each replacement, wrapping back
    to head, if necessary. Default token value is "%s"
    reference: (/with <token>) Custom token
Function: prinxTopGlobals IndexBackNext
    syntax: prinx <str> <int-reps> prin S reps number of times
    refinement: /only Use print instead of prin
Function: pull-someTopGlobals IndexBackNext
    syntax: pull-some <string> <string-unwanted>
    description: Remove all characters found in unwanted from string
Function: randAlphaNumTopGlobals IndexBackNext
    syntax: randAlphaNum <int-len> len random characters chosen from
     the alphanumeric set
Function: random-stringTopGlobals IndexBackNext
    syntax: random-string <str-chars> <int-len>
    Description: Returns returns string of len characters chosen from chars
Function: remove-allTopGlobals IndexBackNext
    syntax: remove-all <string> <block-or-str-subs>
    description: remove all substrings in subs from str
Function: rephraseTopGlobals IndexBackNext
    syntax: rephrase <string> <int-limit>
    Description: Returns a shortened phrase with no more words than limit.
    Note: If original number of words is greater than limit, prepend with ...'
Function: requoteTopGlobals IndexBackNext
    syntax: requote <string> Returns string with literal double quotes
Function: rfillTopGlobals IndexBackNext
    syntax: rfill <string> <chars> Pad string S with chars on the right,
      to fill a field to the specified width. Do not truncate.
Function: RightTopGlobals IndexBackNext
    syntax: Right <S-series> <int-len>
    description: Return last part of series. Determined by len.
Function: siftTopGlobals IndexBackNext
    syntax: sift <string> <str-start> <str-stop> <any-outer-mark> <any-inner-mark>
    description: Seperates text between <start> and <stop> delimiters (inner text) from other text.
    description: sift "abc@cde*fgh" "@" "*" 1 2 => [[1 "abc"] [2 "cde"] [1 "fgh"]]
Function: slicesTopGlobals IndexBackNext
    syntax: slices <series> <block-of-ints-endpoints>
    description: Return a block of slices of series.
    Note: Each endpoint measures from the previous
Function: splitTopGlobals IndexBackNext
    syntax: split <string> <str-char-sep>
    description: Converts string to block delimited by <sep>.
    Note: If <sep> at end, append "", if <sep> at start, insert <sep>
    Refinement: /with Include <sep> with output
Function: split-onTopGlobals IndexBackNext
    syntax: split-on <str> <str-char-sep> Splits string on first occurrence of sep
Function: splitcTopGlobals IndexBackNext
    syntax: splitc <str> <str-chars> Split a string on any number of single character delimiters
Function: splitsTopGlobals IndexBackNext
    syntax: splits <string> seps<block-or-string> Parse str on seps - multiple delimiters.
Function: sql-quoteTopGlobals IndexBackNext
    syntax: sql-quote <str-str> Return <str> with mysql special characters escaped
    see: http://www.mysql.com/doc/en/String_syntax.html
Function: stripTopGlobals IndexBackNext
    syntax: strip <string> <unwanted-chars>
    description: Create string from S with leading/trailing chars removed
    refinement: /end Remove from end only /front remove from front only
Function: strsTopGlobals IndexBackNext
    syntax: strs <str-substr> <int-iterations>
    description: Create a string with n iterations of substring
    example: strs "hi " 8 => "hi hi hi hi hi hi hi hi "
Function: substrTopGlobals IndexBackNext
    syntax: substr <S-series> <int-skipped> <int-len>
    description: Return subset of a series. Original value is unchanged.
    arg: <int-start> position to start at
    arg: <int-len> Amount to copy. Ignore overrun.
Function: substringsTopGlobals IndexBackNext
    syntax: substrings <series-S> <block-segment>
    description: Return block of substrings.
    arg: <nested-block-segments> Inner blocks are begin points and lengths.
Function: takeTopGlobals IndexBackNext
    syntax: take <string> <str-start> <str-stop>
    description: Removes text between start and stop delimiters
    refinement: /less Retain delimiters
    example: take "name (not here) tim" "(" ")" =>
"name tim"
    example: take/less "name (not here) tim" "(" ")" =>
"name () tim"
Function: to-titleTopGlobals IndexBackNext
    syntax: to-title <str-s>
    description: Force a string to lowercase with first character uppercase.
Function: truncateTopGlobals IndexBackNext
    syntax: truncate <series> <int-maxlen> Insure that series is no longer than length
Function: un-escTopGlobals IndexBackNext
    syntax: un-esc <string> Returns string with mysql special characters un-escaped
Function: un-esc-blkTopGlobals IndexBackNext
    syntax: un-esc-blk <block> Returns block with string items un-esc'd
     see http://www.mysql.com/doc/en/String_syntax.html for escaping mysql special characters
Function: unformTopGlobals IndexBackNext
    syntax: unform <str> Parse a string on spaces. Returns block
    Note!: no empty string returned in block
Function: word-wrapTopGlobals IndexBackNext
    syntax: word-wrap <string> <int-width>
    description: returns a block of space-delimited strings with break tags
    or newlines inserted after <width> is reached.
    refinement: /H Use html break tags and escape characters.
Function: zfillTopGlobals IndexBack
    syntax: zfill <string> <width>
    description: Pad string S with zeros on the left, to fill a field
      to the specified width. The string S is never truncated.

Global function documentation