Replace: Rewrite a string using capture groups¶
- class txf.Replace(source, input, search, replace)¶
The
Replacetransform uses a regular expresssion to reformat a field using capture groups.Replaceis a subclass ofFormat.- input: str¶
The name of the string field to apply the pattern to. The contents will be replaced, so use
Copyto preserve the original.
- search: str¶
A regular expression with capture groups that can be referenced in the replace string. If the pattern does not match, the value is unchanged. To avoid this, use
Dividewith the same pattern to isolate the values that match.
- replace: str¶
An expansion string with references to capture groups, using Python’s
expandnotation.
Usage¶
Replace(p, 'US Date', '(d+)/(d+)/(d+)', '\3-\2-\1')