Description Usage Arguments Details Value Examples
Create or test for parser objects. These objects will be used by templates to identify a field within a log file.
1 2 3 |
x |
A regex string, a parser, or a list of either; Or object to be tested |
f |
A function to format the captured output, or a named list of such
functions if |
name |
An optional name for the parser |
Parser objects contain 3 things:
A regex expression that matches the given field
A 'formatter'; a function that will in some way modify the captured text
By default, this the identity function
(Optional) A name for the parser
parser
and its S3 methods coerce x
to a parser
object,
returning said parser object. is.parser
returns TRUE or FALSE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Captures integers
parser('[0-9]+')
# Captures integers, cast to integers
parser('[0-9]+', as.integer)
# List of parsers, all named (inferred from list names), some with parsers
parser(
list(
ip = '[0-9]{1,3}(\\.[0-9]{1,3}){3}',
int = '[0-9]+',
date = '[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}'
),
list(int = as.integer, date = as.Date)
)
is.parser(parser('[0-9]+')) #TRUE
is.parser(100) #FALSE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.