Lazy RE
|
Lazy RE. More...
#include <sys/types.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lazy_re.h"
Classes | |
struct | RegexCache |
Represents Regex cache. More... | |
Macros | |
#define | REGEX_ASSERT(condition, msg) assert((condition) || !printf("REGEX_ERROR: %s\n", msg)) |
Assert to check regex functions input parameters. More... | |
Functions | |
void | Regex_compile (regex_t *regex, const char *pattern, const int cflags) |
Compiles regex. More... | |
void | Regex_free (regex_t *regex) |
Frees memory allocated for regex. More... | |
bool | Regex_test (const char *pattern, const char *string) |
Test whether pattern presents in a string. More... | |
RegexMatch * | Regex_compiledSearch (regex_t *regex, const char *string, const int eflags) |
Search a first occurrence of a regex in a string. More... | |
RegexMatch * | Regex_search (const char *pattern, const char *string, const int eflags) |
Search first occurrence of a pattern in a string. More... | |
RegexMatch * | Regex_searchNext () |
Performs next search from cache of the last successful one. More... | |
Lazy RE.
It is based on POSIX regular expression:
http://www.regular-expressions.info/posix.html
Special characters: .[{}()\*+?|^$
#define REGEX_ASSERT | ( | condition, | |
msg | |||
) | assert((condition) || !printf("REGEX_ERROR: %s\n", msg)) |
Assert to check regex functions input parameters.
condition | Assert condition. |
msg | Pointer to string with message. |
void Regex_compile | ( | regex_t * | regex, |
const char * | pattern, | ||
const int | cflags | ||
) |
Compiles regex.
Regex cflags reference http://www.gnu.org/software/libc/manual/html_node/Flags-for-POSIX-Regexps.html#Flags-for-POSIX-Regexps
regex | Pointer to a struct with regex. |
pattern | String containing regex. |
cflags | Regex flags with which regex is created. |
RegexMatch* Regex_compiledSearch | ( | regex_t * | regex, |
const char * | string, | ||
const int | eflags | ||
) |
Search a first occurrence of a regex in a string.
Regex eflags reference http://www.gnu.org/software/libc/manual/html_node/Matching-POSIX-Regexps.html#Matching-POSIX-Regexps
regex | Regex which will be used to match. |
string | String against which to perform match. |
eflags | Regex flags with which to match. |
void Regex_free | ( | regex_t * | regex | ) |
Frees memory allocated for regex.
regex | Regex struct. |
RegexMatch* Regex_search | ( | const char * | pattern, |
const char * | string, | ||
const int | eflags | ||
) |
Search first occurrence of a pattern in a string.
Regex eflags reference http://www.gnu.org/software/libc/manual/html_node/Matching-POSIX-Regexps.html#Matching-POSIX-Regexps
regex | Pattern which will be used to match. |
string | String against which to perform match. |
eflags | Regex flags with which to match. |
RegexMatch* Regex_searchNext | ( | ) |
Performs next search from cache of the last successful one.
bool Regex_test | ( | const char * | pattern, |
const char * | string | ||
) |
Test whether pattern presents in a string.
regex | Pattern which will be used to match. |
string | String against which to perform match. |
true | If pattern is found. |
false | otherwise. |