Regex Parser
The Regex parser is used for parsing incoming data using regular expressions. To use it set
decoder
to regex
and use regular expressions in your root schema’s source
, with the capture
groups in sub-schemas’ source
.
For more information about the syntax visit https://github.com/google/re2/wiki/Syntax.
To test your regular expressions we recommend using https://regex101.com/ and selecting the
Golang
flavour.
Example
Incoming data:
The URL http://example.com/foo has been visited 2835 times.
Decoder configuration:
decoder: regex
schema:
type: object
source: ^The URL (.+) has been visited (\d+) times\.$ # Regular expression specifying capture groups.
properties:
url:
type: string
source: $1 # Fetch first capture group.
visits:
type: integer
source: $2 # Fetch second capture group.
Outputs:
url: http://example.com/foo
visits: 2835