f56f480add42cd89cb03aa1fc6ff503a1c5e4203 kent Thu Aug 15 09:01:34 2019 -0700 Made now return time in the ISO 1806 format variant the expresses it in local time with an offset to GMT. Moved around some sections in the doc file. diff --git src/lib/strex.doc src/lib/strex.doc index a6fd423..aceca45 100644 --- src/lib/strex.doc +++ src/lib/strex.doc @@ -1,45 +1,21 @@ The strex language is a small string expression evaluation language. This document describes its built in functions and operators: + - returns the concatenation of the surrounding strings or the addition of surrounding numbers. Will convert a number to a string in mixed expressions -or - logical or operation extended to strings and numbers. - for logic - if any or-separated-values are true, return true, else false - for numbers - if any or-separated non-zero numbers exist, return first one else 0 - for strings - if any or-separated non-empty strings exists, return first one else "" - In mixed operations result is converted to strings if strings are involved or - the values "" and "true" if no strings are involved. - For the pure string case this can be useful for setting defaults as well. For - instance presuming you might or might not have filled in values for the city or country - variables in the given expression that would return a location of some sort - (city or country or "somewhere in the universe") - Note the parenthesis around the ors is good to have because of the very low - precedence of the logical operators. - -and - logical and operation extended to strings and numbers - for logic - if all and-separated-values are tru, return true, else false - for numbers - if all numbers are non-zero return true else false - for strings - if all and-separated strings are nonempty, return true, else "" - In mixed operations result is converted to strings if strings are involved or - the values "" and "true" if no strings are involved. - -returns first nonempty string or non-zero number on either side of | or "" if all empty -& - returns first empty string or zero on either side of & or right side if all non-empty - - [index] - selects a character from string given an integer zero based index. As in Python if index is negative it selects characters from the end of the string. -1 corresponds to the last character of string, as 0 corresponds to first. Returns empty string if index out of range. between(prefix, string, suffix) - returns the part of string found between prefix and suffix example: between("abc", "01234abcHelloxyz56789", "xyz") fetches just "Hello" If there are multiple places the prefix occurs, it will choose the first one, and the then the first place the suffix matches after that. The biologist might think of it as a text oriented PCR, though the primer prefix and suffixes are not included in the output. The prefix "" corresponds to beginning of string and the suffix "" corresponds to end. Returns empty string if nothing found. split(string, index) - white space separated word from string of given 0 based index. Returns empty string if index is too large. @@ -114,17 +90,39 @@ (boolean ? trueVal : falseVal) This is the trinary conditional expression found in C, Python and many other languages. If the boolean before the question mark is true, then the result is the trueVal before the colon, otherwise it's the falseVal after the colon. Empty strings and zeros as booleans are considered false, other strings and numbers true. in(string, query) - returns true if query is a substring of string, false otherwise same(a, b) - returns true if the two arguments are the same, false otherwise starts(prefix, string) - returns true if string starts with prefix ends(string, suffix) - returns true if string ends with suffix -now() - returns current time and date in a really aweful unix ctime(2) format. We will improve it. +or - logical or operation extended to strings and numbers. + for logic - if any or-separated-values are true, return true, else false + for numbers - if any or-separated non-zero numbers exist, return first one else 0 + for strings - if any or-separated non-empty strings exists, return first one else "" + In mixed operations result is converted to strings if strings are involved or + the values "" and "true" if no strings are involved. + For the pure string case this can be useful for setting defaults as well. For + instance presuming you might or might not have filled in values for the city or country + variables in the given expression that would return a location of some sort + (city or country or "somewhere in the universe") + Note the parenthesis around the ors is good to have because of the very low + precedence of the logical operators. + +and - logical and operation extended to strings and numbers + for logic - if all and-separated-values are tru, return true, else false + for numbers - if all numbers are non-zero return true else false + for strings - if all and-separated strings are nonempty, return true, else "" + In mixed operations result is converted to strings if strings are involved or + the values "" and "true" if no strings are involved. + +now() - returns current time and date in ISO 1806 format using the variant that has the local + time and timezone, for instance 2019-08-14T23:35:22-0700 for 11:35 pm in California + during daylight savings time.