The STRUCTURE{ matcher_expression } matcher allows capturing any sequence of matchers in record data type.
Use the following expression to parse the value:
STRUCTURE{ INT:i ',' LD:string }:result
For example, capturing an integer and a string as one record:
| Description | input (string) | result (record) |
|---|---|---|
Integer and string members |
|
|
Invalid input |
|
|
Whitespace |
|
|
data record(input = "1,red fox jumps"),record(input = "random text"),record(input = " ")| parse input, "STRUCTURE{ INT:i ',' LD:string }:result"
STRUCTURE{ matcher_expression }:result
The data type of the extracted value is record. Each named member becomes a field in the record, keeping the data type of its matcher.
Wrap part of the pattern in ( ... )? to make members optional. When the optional part is absent, its members are null and the structure still matches.
Use the following expression to capture a client address and an optional port:
STRUCTURE{ IPADDR:client (SPACE INT:port)? }:result
input (string) | result (record) |
|---|---|
|
|
|
|
data record(input = "10.0.0.1 8080"),record(input = "10.0.0.1")| parse input, "STRUCTURE{ IPADDR:client (SPACE INT:port)? }:result"
A structure can contain another structure, producing a nested record.
Given the following input:
Vienna 48.2,16.3
Use the following expression to capture the city and a nested coordinate record:
STRUCTURE{ WORD:city SPACE STRUCTURE{ DOUBLE:lat ',' DOUBLE:lon }:coords }:result
result (record) |
|---|
|
data record(input = "Vienna 48.2,16.3")| parse input, "STRUCTURE{ WORD:city SPACE STRUCTURE{ DOUBLE:lat ',' DOUBLE:lon }:coords }:result"
Wrap a structure in an ARRAY to capture a repeating group as an array of records, then use expand to emit one row per element.
Given the following input, a comma-separated list of folder paths and file counts:
C:\ftp\acme=0,C:\ftp\acme\INBOUND\Claims=2,C:\ftp\acme\INBOUND\Contribution=0,C:\ftp\acme\INBOUND\Enrollment=0
Use the following expression to capture each path and count as a record:
ARRAY{STRUCTURE{LD:key '=' INT:value}:i ','?}{0,100}:result
result[key] (string) | result[value] (long) |
|---|---|
|
|
|
|
|
|
|
|
data record(input = """C:\ftp\acme=0,C:\ftp\acme\INBOUND\Claims=2,C:\ftp\acme\INBOUND\Contribution=0,C:\ftp\acme\INBOUND\Enrollment=0""")| parse input, """ARRAY{STRUCTURE{LD:key '=' INT:value}:i ','?}{0,100}:result"""| expand result