Lazy RE
lazy_re.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <regex.h>
9 #include <stdbool.h>
10 
12 #define REGEX_MAX_GROUP 10
13 
21 typedef struct {
22  regmatch_t innerGroups[REGEX_MAX_GROUP];
23  char *groups[REGEX_MAX_GROUP];
24 } RegexMatch;
25 
35 void Regex_compile(regex_t *regex, const char* pattern, const int cflags);
41 void Regex_free(regex_t* regex);
42 
52 bool Regex_test(const char* pattern, const char* string);
64 RegexMatch* Regex_search(const char* pattern, const char* string, const int eflags);
65 
78 RegexMatch* Regex_compiledSearch(regex_t* regex, const char* string, const int eflags);
79 
bool Regex_test(const char *pattern, const char *string)
Test whether pattern presents in a string.
Definition: lazy_re.c:91
#define REGEX_MAX_GROUP
Max number of groups in match.
Definition: lazy_re.h:12
RegexMatch * Regex_search(const char *pattern, const char *string, const int eflags)
Search first occurrence of a pattern in a string.
Definition: lazy_re.c:128
RegexMatch * Regex_compiledSearch(regex_t *regex, const char *string, const int eflags)
Search a first occurrence of a regex in a string.
Definition: lazy_re.c:102
Represents regex match.
Definition: lazy_re.h:21
void Regex_compile(regex_t *regex, const char *pattern, const int cflags)
Compiles regex.
Definition: lazy_re.c:80
void Regex_free(regex_t *regex)
Frees memory allocated for regex.
Definition: lazy_re.c:86
RegexMatch * Regex_searchNext()
Performs next search from cache of the last successful one.
Definition: lazy_re.c:148