Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
cookbooks:transformations:devel [2010/04/20 16:15] 85.178.143.171 dcm: documented s.strip and s.striptail |
cookbooks:transformations:devel [2011/11/09 12:34] (current) 193.146.38.124 old revision restored |
||
---|---|---|---|
Line 66: | Line 66: | ||
< | < | ||
- | xlog("MD4 over From username: $(fU{s.md5})" | + | xlog("md5 over From username: $(fU{s.md5})" |
</ | </ | ||
+ | |||
==== {s.substr, | ==== {s.substr, | ||
Line 153: | Line 154: | ||
Return string after removing ending ' | Return string after removing ending ' | ||
+ | |||
+ | ==== {s.prefixes[, | ||
+ | |||
+ | Return series of comma separated prefixes of the pv. Parameter ' | ||
+ | |||
+ | Example: | ||
+ | <code c> | ||
+ | $var(x) = " | ||
+ | $(var(x){s.prefixes}) => 1, | ||
+ | $(var(x){s.prefixes, | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== {s.prefixes.quoted[, | ||
+ | |||
+ | Return series of comma separated quoted prefixes of the pv. Parameter ' | ||
+ | |||
+ | Example: | ||
+ | <code c> | ||
+ | $var(x) = " | ||
+ | $(var(x){s.prefixes.quoted} => ' | ||
+ | $(var(x){s.prefixes.quoted, | ||
+ | </ | ||
===== URI Transformations ===== | ===== URI Transformations ===== | ||
Line 332: | Line 356: | ||
<hi # | <hi # | ||
- | Access parts of a ToBody-like structure. | ||
- | |||
==== {re.subst, | ==== {re.subst, | ||
Line 339: | Line 361: | ||
Perform Perl-like substitutions on string value pseudo-variables. | Perform Perl-like substitutions on string value pseudo-variables. | ||
- | < | + | < |
# Assign Request-URI user to PV | # Assign Request-URI user to PV | ||
$var(user) = $(ru{re.subst,/ | $var(user) = $(ru{re.subst,/ | ||
</ | </ | ||
- | < | + | < |
# Assign Request-URI user to PV, where every ' | # Assign Request-URI user to PV, where every ' | ||
- | $var(user) = $(rU{re.subst,/ | + | $var(user) = $(rU{re.subst,/ |
</ | </ | ||
+ | |||
+ | The prototype is: | ||
+ | |||
+ | <code c> | ||
+ | {re.subst,/ | ||
+ | </ | ||
+ | |||
+ | * match_expression - Posix regular expression | ||
+ | * replacement_expression - substitution expression with back references to matched tokes: \1, \2, ..., \9 | ||
+ | * flags: | ||
+ | * i - match ignore case | ||
+ | * s - match within multi-lines strings | ||
+ | * g - replace all matches | ||
+ | |||
+ | ===== SQL Transformations ===== | ||
+ | |||
+ | <hi # | ||
+ | |||
+ | ==== {sql.val} ==== | ||
+ | |||
+ | This transformation outputs valid SQL values for various PV values: | ||
+ | * < | ||
+ | * integers are output as integers | ||
+ | * everything else is output as quoted and escaped string | ||
+ | | ||
+ | <code c> | ||
+ | $var(null) = $null; | ||
+ | $avp(null) = $null; | ||
+ | $avp(str) = " | ||
+ | $avp(nr) = 12345; | ||
+ | $avp(strnr) = " | ||
+ | | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | xlog(" | ||
+ | |||
+ | Output: | ||
+ | $rm = ACK = ' | ||
+ | $var(null) = 0 = 0 | ||
+ | $avp(null) = < | ||
+ | $avp(str) = String with \ illegal \characters = ' | ||
+ | $avp(nr) = 12345 = 12345 | ||
+ | $avp(strnr) = 12345 = ' | ||
+ | </ | ||
+ | |||
+ | ==== {sql.val.int} ==== | ||
+ | |||
+ | Like sql.val, but output number 0 for null values. | ||
+ | |||
+ | ==== {sql.val.str} ==== | ||
+ | |||
+ | Like sql.val, but output string '' | ||
===== Examples ===== | ===== Examples ===== |