Replace: Rewrite a string using capture groups¶
- class txf.Replace(source, input, search, replace)¶
The
Replace
transform uses a regular expresssion to reformat a field using capture groups.Replace
is a subclass ofFormat
.- input: str¶
The name of the string field to apply the pattern to. The contents will be replaced, so use
Copy
to 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
Divide
with the same pattern to isolate the values that match.
- replace: str¶
An expansion string with references to capture groups, using Python’s
expand
notation.
Usage¶
Replace(p, 'US Date', '(d+)/(d+)/(d+)', '\3-\2-\1')