grokex v0.1.0 GrokEX
Compiles grok patterns into Elixir objects which can be used for testing strings against patterns.
Examples
iex> GrokEX.compile_regex("Here's a number %{NUMBER:the_number}")
{:ok,
~r/Here's a number (?<the_number>(?:(?<![0-9.+-])(?>[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+)))))/}
iex> GrokEX.compile_predicate("User %{QUOTEDSTRING:username} connected from %{IP:user_address}")
#Function<0.46228848/1 in GrokEX.compile_predicate/2>
Link to this section Summary
Functions
Compiles a grok pattern to a function that takes a string and returns either the
named captures if the string matches the pattern, or :no_match
if the string
doesn't match.
Compiles a grok pattern to a function that takes a string and returns either the
named captures if the string matches the pattern, or :no_match
if the string
doesn't match.
Link to this section Types
compile_opts()
Specs
grok_predicate()
Specs
Link to this section Functions
compile_predicate(string, opts \\ [])
Specs
compile_predicate(String.t(), [compile_opts()]) :: {:ok, grok_predicate()} | {:error, term()}
Compiles a grok pattern to a function that takes a string and returns either the
named captures if the string matches the pattern, or :no_match
if the string
doesn't match.
Examples
iex> GrokEX.compile_predicate("User %{QUOTEDSTRING:username} connected from %{IP:user_address}")
Options
:patterns
- Provide custom patterns to the grok compiler. These patterns will be merged with the default patterns
compile_regex(string, opts \\ [])
Specs
compile_regex(String.t(), [compile_opts()]) :: {:ok, Regex.t()} | {:error, term()}
Compiles a grok pattern to a function that takes a string and returns either the
named captures if the string matches the pattern, or :no_match
if the string
doesn't match.
Examples
iex> GrokEX.compile_regex("User %{QUOTEDSTRING:username} connected from %{IP:user_address}")
Options
:patterns
- Provide custom patterns to the grok compiler. These patterns will be merged with the default patterns