Match: Filter rows using a regular expression¶
- class txf.Match(source, input, pattern[, invert=False])¶
The
Match
transform filters rows based on a regular expression.Match
is a subclass ofSelect
.- input: str¶
The name of the column to apply the pattern to.
- pattern: str¶
A regular expression to match against the input.
- invert: Boolean¶
Negative matching is difficult to specify with regular expressions, so this lets the caller reject rows that match a pattern.
Usage¶
Match(p, 'Date', r'(\d+)/(\d+)/(\d+)') # Filter to valid dates
Match(p, 'Line', '-----', True) # Exclude formatting lines
Example¶
Line |
---|
—-—-—-—-– |
|| Q01_PARALLEL || |
—-—-—-—-– |
Cold run…DONE |
1/5…0.083052 |
2/5…0.079075 |
3/5…0.079176 |
4/5…0.078928 |
5/5…0.079142 |
—-—-—-—-– |
Match(p, 'Line', '-----', True)
Line |
---|
|| Q01_PARALLEL || |
Cold run…DONE |
1/5…0.083052 |
2/5…0.079075 |
3/5…0.079176 |
4/5…0.078928 |
5/5…0.079142 |