Capture: Split a string into capture groups¶
- class txf.Capture(source, input, outputs, pattern[, defaults = ''])¶
The
Capture
transform replaces a string field with the capture groups from a regular expression.Capture
is a subclass ofSplit
.- input: str¶
The name of the string field to apply the pattern to. It will be dropped from the output, so use
Copy
to preserve it.
- outputs: tuple(str), str¶
The the output field(s)s receiving the capture groups. There must be the same number as the number of capture groups in the pattern.
- pattern: str¶
A regular expression with one or more capture groups.
- defaults: tuple(str), str¶
If the pattern does not match, the first output will contain the original string and the remaining outputs will be filled with the value(s) in defaults. If defaults is not a single value, it must be the same size as the number of outputs.
Usage¶
Capture(p, 'Date', ('Month', 'Day', 'Year',), r'(\d+)/(\d+)/(\d+)')
Capture(p, 'Query', 'Query', r'Q(\d+)')
Example¶
Query |
Mode |
Run |
Branch |
---|---|---|---|
1 |
PARALLEL |
1/5…0.083052 |
master |
1 |
PARALLEL |
2/5…0.079075 |
master |
1 |
PARALLEL |
3/5…0.079176 |
master |
1 |
PARALLEL |
4/5…0.078928 |
master |
1 |
PARALLEL |
5/5…0.079142 |
master |
Capture(p, 'Run', ('Run #', 'Run Count', 'Time',), r'(\d+)/(\d+)...(\d+\.\d+)')
Query |
Mode |
Run # |
Run Count |
Time |
Branch |
---|---|---|---|---|---|
1 |
PARALLEL |
1 |
5 |
0.083052 |
master |
1 |
PARALLEL |
2 |
5 |
0.079075 |
master |
1 |
PARALLEL |
3 |
5 |
0.079176 |
master |
1 |
PARALLEL |
4 |
5 |
0.078928 |
master |
1 |
PARALLEL |
5 |
5 |
0.079142 |
master |