Hyperscan (hyperscan v0.1.0)
Summary
Functions
Allocate a scratch memory buffer for use by when running the regular expression.
Compile a regular expression into a database.
Compile a regular expression into a database.
Returns a map with debugging info about a regular expression.
Returns the integer value of the flag constant with the given name. Names follow the pattern HSFLAG*. The value is used by the compile and compile_multi functions. To use multiple flags simultaneously, combine their values with Bitwise.bor/2.
Test whether the given compiled regex matches a string. Requires a scratch buffer allocated by alloc_scratch/1.
Test whether multiple compiled regexes match a string. The regex should be compiled by compile_multi. Returns a list of expression IDs that matched the string. Note that the order of the returned IDs is undefined.
Returns the integer value of the mode constant with the given name. Names follow the pattern HSMODE*.
Re-allocate a scratch memory buffer. If the scratch was allocated for a different database and is too small for the given one, it will be reallocated. Returns :ok.
Returns true if the current system architecture supports , otherwise false.
Returns the compiled version of , as a string.
Functions
alloc_scratch(db)
Allocate a scratch memory buffer for use by when running the regular expression.
clone_scratch(scratch)
compile(expression, flags, mode, platform)
Compile a regular expression into a database.
expression
is a regular expression, without the leading/trailing/
characters or flags.flags
is an integer. Use 0 for no flags, or bitwise-or together one or more results of the flags/1 function.mode
is an integer similar toflags
.platform
. Either the result ofpopulate_platform
or nil.
See the docs for more information: http://intel.github.io/hyperscan/dev-reference/api_files.html#c.hs_compile
compile_multi(expression_list, flags_list, id_list, mode, platform)
Compile a regular expression into a database.
expression
is a regular expression, without the leading/trailing/
characters or flags.flags
is an integer. Use 0 for no flags, or bitwise-or together one or more results of the flags/1 function.mode
is an integer similar toflags
.platform
. Either the result ofpopulate_platform
or nil.
See the docs for more information: http://intel.github.io/hyperscan/dev-reference/api_files.html#c.hs_compile
expression_info(expression, flags)
Returns a map with debugging info about a regular expression.
flag(name)
Returns the integer value of the flag constant with the given name. Names follow the pattern HSFLAG*. The value is used by the compile and compile_multi functions. To use multiple flags simultaneously, combine their values with Bitwise.bor/2.
Raises :badarg if it is not a valid flag name.
init()
match(db, string, scratch)
Test whether the given compiled regex matches a string. Requires a scratch buffer allocated by alloc_scratch/1.
match_multi(db, string, scratch)
Test whether multiple compiled regexes match a string. The regex should be compiled by compile_multi. Returns a list of expression IDs that matched the string. Note that the order of the returned IDs is undefined.
mode(name)
Returns the integer value of the mode constant with the given name. Names follow the pattern HSMODE*.
Raises :badarg if it is not a valid mode name.
realloc_scratch(db, scratch)
Re-allocate a scratch memory buffer. If the scratch was allocated for a different database and is too small for the given one, it will be reallocated. Returns :ok.
scratch_size(scratch)
valid_platform()
Returns true if the current system architecture supports , otherwise false.
version()
Returns the compiled version of , as a string.