raw

Operations on raw (non-JSON) data

raw to-json

Wrap plain text as a JSON field

Type: field

Example

input:

some text

action:

raw:
  to-json: some-field

output:

{"some-field":"some text"}

raw discard-until

A pattern that must match before data starts to be processed

All data before then will be discarded. An example of where this is useful is where the data would start with comments.

Type: regex

Example

input:

# some comment
# some other comment
num=1
num=2
num=3

action:

raw:
  discard-until: '^num'

output:

num=1
num=2
num=3

raw extract

Extract data from plain text, using a pattern

Field NameDescriptionTypeDefault
input-fieldField containing datafield-
patternThe pattern to match onregex-
replaceReplacement textstring-

input-field

Field containing data

Type: field

Example

input:

{"one":"1"}

action:

raw:
  extract:
    input-field: one
    replace: we got $0

output:

{"one":"we got 1"}

pattern

The pattern to match on

If replace is not provided, the first match is the output

Type: regex

Example

input:

num=1
num=2
num=3

action:

raw:
  extract:
    pattern: 'num=(\d+)'

output:

1
2
3

replace

Replacement text

If pattern is not provided, the whole input is still available as $0.

Note that $0 refers to entire text, $1 first regex group match, $2 second one, and so on...

Type: string

Example

input:

num=1
num=2
num=3

action:

raw:
  extract:
    pattern: 'num=(\d+)'
    replace: we got $1

output:

we got 1
we got 2
we got 3

raw replace

Replace data from plain text, using a pattern

The difference between this and extract is that it will never fail

Field NameDescriptionTypeDefault
input-fieldField containing datafield-
patternThe pattern to match onregex-
substitutionReplacement textstring-

input-field

Field containing data

Type: field

Example

input:

{"one":"hey 1"}

action:

raw:
  replace:
    input-field: one
    pattern: 'hey (\d+)'
    substitution: we got $1

output:

{"one":"we got 1"}

pattern

The pattern to match on

Type: regex

Example

input:

{"num":"1"}
{"text":"one"}

action:

raw:
  replace:
    pattern: one
    substitution: we got $0

output:

{"num":"1"}
{"text":"we got one"}

Example

input:

{"num":"1"}
{"text":"one"}

action:

raw:
  replace:
    pattern: (\d+)
    substitution: prefix of $1

output:

{"num":"prefix of 1"}
{"text":"one"}

substitution

Replacement text

Note that $0 refers to entire text, $1 first regex group match, $2 second one, and so on...

Type: string