extractParseAnchor

Extract a token matching a pattern.

Compare a pattern (custom regex) to a string then return the Nth token, where N is specified as part of the input. This function improves readability of a pattern that contains only '*'. It doesn't do extensive regex.

Usage Details

select extractParseAnchor(column, pattern, '$N') as resultCol from table

Input:

table: Input table.
pattern: Parameter, a custom regex pattern like "logiccom" (same as "^logic.com$" in Java).
column: Column name to match pattern.
$N: Extract Nth token.

Output:

Returns Nth token

Example

Input
table

sourcePort
'A emil B logic C'
'A test B util'
select *, extractParseAnchor(col, 'A * B * C', '$2') as a result from table

Output

sourcePort result
'A emil B logic C'emil
'A test B util'test

© 2017-2021 LogicHub®. All Rights Reserved.