Documentation ¶
Index ¶
- Variables
- func ContainsPattern(_ *transformctx.Ctx, regexPattern string, strs ...string) (string, error)
- func Eval(_ *transformctx.Ctx, exprStr string, args ...string) (string, error)
- func External(ctx *transformctx.Ctx, name string) (string, error)
- func Floor(_ *transformctx.Ctx, valueStr, decimalPlaces string) (string, error)
- func IfElse(_ *transformctx.Ctx, conditionsAndValues ...string) (string, error)
- func IsEmpty(_ *transformctx.Ctx, str string) (string, error)
- func RSubstring(ctx *transformctx.Ctx, str, startIndex, lengthStr string) (string, error)
- func Replace(_ *transformctx.Ctx, s, regexStr, replStr string) (string, error)
- func RetrieveBySplit(_ *transformctx.Ctx, str, sep, indexStr string) (string, error)
- func RowSkip(_ *transformctx.Ctx, value, skipRegex string) (string, error)
- func SplitIntoJSONArray(_ *transformctx.Ctx, s, sep string, trim ...string) (string, error)
- func StrEqualAny(_ *transformctx.Ctx, s string, others ...string) (string, error)
- func Substring(_ *transformctx.Ctx, str, startIndex, lengthStr string) (string, error)
- func SwitchByPattern(_ *transformctx.Ctx, value string, patternsAndValues ...string) (string, error)
- func SwitchFunc(ctx *transformctx.Ctx, value string, casesAndValues ...string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var OmniV10CustomFuncs = customfuncs.Merge( customfuncs.CommonCustomFuncs, OmniV10OnlyCustomFuncs)
OmniV10CustomFuncs contains all custom funcs supported by omniparser '1.0'.
var OmniV10OnlyCustomFuncs = map[string]customfuncs.CustomFuncType{ "containsPattern": ContainsPattern, "dateTimeToRfc3339": customfuncs.DateTimeToRFC3339, "dateTimeWithLayoutToRfc3339": customfuncs.DateTimeLayoutToRFC3339, "epochToDateTimeRfc3339": customfuncs.EpochToDateTimeRFC3339, "eval": Eval, "external": External, "floor": Floor, "ifElse": IfElse, "isEmpty": IsEmpty, "replace": Replace, "retrieveBySplit": RetrieveBySplit, "rowSkip": RowSkip, "rsubstring": RSubstring, "splitIntoJsonArray": SplitIntoJSONArray, "strEqualAny": StrEqualAny, "substring": Substring, "switch": SwitchFunc, "switchByPattern": SwitchByPattern, }
OmniV10OnlyCustomFuncs contains omniparser '1.0' specific custom funcs.
Functions ¶
func ContainsPattern ¶
ContainsPattern checks if any of 'strs' matches the given regex pattern, returns "true" if yes, and "false" if no.
func Eval ¶
Eval evaluates a given expression with input params and return the result in string. For supported expression formats and operators, check: https://github.com/Knetic/govaluate/blob/master/MANUAL.md
func External ¶
func External(ctx *transformctx.Ctx, name string) (string, error)
External looks up an external property value by name and fails if not found.
func Floor ¶
func Floor(_ *transformctx.Ctx, valueStr, decimalPlaces string) (string, error)
Floor parses 'valueStr' in as a float64 and then floors/truncates it to the specified decimal places.
func IfElse ¶
func IfElse(_ *transformctx.Ctx, conditionsAndValues ...string) (string, error)
IfElse does a 'if-elseif-elseif-...-else' pattern check and returns the value that meets the condition. Note 'conditionsAndValues' must be of odd length, each of the even values is a condition value and it should be a boolean string and each of the odd values is a value to be returned, should its corresponding condition value is "true".
func IsEmpty ¶
func IsEmpty(_ *transformctx.Ctx, str string) (string, error)
IsEmpty returns "true" if 'str' is empty; false if 'str' isn't. Note blank string (with whitespace only) is not considered empty.
func RSubstring ¶
func RSubstring(ctx *transformctx.Ctx, str, startIndex, lengthStr string) (string, error)
RSubstring extracts a part of a 'str' from 'startIndex' from the right end of the string with length equal to 'lengthStr'. 'startIndex' must be [0, len). 'lengthStr' can be '-1', in which case RSubstring will return all the remaining characters (towards the head) of 'str' starting from 'startIndex' from the right. Or 'lengthStr' can be >= 0, in which case RSubstring will only return 'lengthStr' number characters of 'str' starting from 'startIndex' from the right.
func Replace ¶
func Replace(_ *transformctx.Ctx, s, regexStr, replStr string) (string, error)
Replace replaces in 's' all the substrings that matches 'regexStr' with 'replStr'.
func RetrieveBySplit ¶
func RetrieveBySplit(_ *transformctx.Ctx, str, sep, indexStr string) (string, error)
RetrieveBySplit splits a 'str' by 'sep' and returns the 'indexStr'-th part. Note 'indexStr' is 0-based.
func RowSkip ¶
func RowSkip(_ *transformctx.Ctx, value, skipRegex string) (string, error)
RowSkip checks if a 'value' matches 'skipRegex' pattern, and return a special error code NonErrorRecordSkipped to indicate to omniparser '1.0' to skip processing a record, if the pattern matches.
func SplitIntoJSONArray ¶
SplitIntoJSONArray splits an 's' by 'sep' and returns the resulting array of parts in a JSON string. An optional 'trim' argument can be specified to tell the function to space trim each part or not.
func StrEqualAny ¶
StrEqualAny returns true if the 's' is equal to any of the strings specified by 'others'. If 'others' is empty or none of its strings is equal to 's', then "false" is returned.
func Substring ¶
func Substring(_ *transformctx.Ctx, str, startIndex, lengthStr string) (string, error)
Substring extracts a part of a 'str' from 'startIndex' with 'lengthStr'. 'startIndex' must be [0, len). 'lengthStr' can be '-1', in which case Substring will return all the remaining characters of 'str' starting from 'startIndex'. Or 'lengthStr' can be >= 0, in which case Substring will only return 'lengthStr' number characters of 'str' starting from 'startIndex'.
func SwitchByPattern ¶
func SwitchByPattern(_ *transformctx.Ctx, value string, patternsAndValues ...string) (string, error)
SwitchByPattern tests a value against a number of patterns (by regex pattern match) and returns the matched value; if nothing matches, the last default value is returned.
func SwitchFunc ¶
SwitchFunc tests a 'value' against a number of cases (by string literal comparison) and returns the matched value; if nothing matches, the last default value is returned.
Types ¶
This section is empty.