implements a webject to run regular expression substitution on group columns.
NOTE: this alters the input group! to preserve state copy-group before!
pattern matching runs in DOTALL mode. (see http://java.sun.com/docs/books/tutorial/extra/regex/pattern.html)
all params can be repeated, each set is processed separately e.g.,: COL_IN[0], COL_OUT[0], RE[0] etc.
Parameters:
- COL_IN
MANDATORY. name of input column
- COL_OUT
new name for altered contents. if missing COL_IN is altered.
- EMPTY_IF_NO_MATCH
defaults to false, only relevant when creating new colums (COL_IN <> COL_OUT)
tells whether an unaltered value should result in an empty att (else COL_OUT value = COL_IN value)
(NOTE: - in case e.g., you subst "2" by "2" COL_OUT will be emptied if EMPTY_IF_NO_MATCH=true)
- RE
default = .* (whole contents)
the re to match column contents against. use () to remember into $1 etc.
- VERBOSE
default false
will write some info about processing to wtadapter log
- IGNORECASE
default=false
do matching case insensitive.
- GLOBAL
default=false
substitute all occurrences (replaceFirst vs. replaceAll)
- SUBST
default=empty
String to substitute for match. may contain !Col-name! to bring in values from other attributes within the same row
Example: create a column "swap" from a column "one" swapping the 2nd and 3rc char: (abcde -> acbde):
<ie:webject name="re-subst" type="EXT" use="ext.tools.webjects.Subst">
<ie:param name="GROUP_IN" data="g"/>
<ie:param name="COL_IN" data="one"/>
<ie:param name="COL_OUT" data="swap"/>
<ie:param name="RE" data="(?<=.)(.)(.)"/>
<ie:param name="SUBST" data="$2$1"/>
</ie:webject>
Example: create a column "new" from a column "old1" and "old2" so if old1=X and old2=Y new will be "X Y"
<ie:webject name="re-subst" type="EXT" use="ext.tools.webjects.Subst">
<ie:param name="GROUP_IN" data="g"/>
<ie:param name="COL_IN" data="old1"/>
<ie:param name="COL_OUT" data="new"/>
<ie:param name="SUBST" data="$1 !old2!"/>
</ie:webject>