ndn-lite
re.h
Go to the documentation of this file.
1 /*
2  *
3  * Mini regex-module inspired by Rob Pike's regex code described in:
4  *
5  * http://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html
6  *
7  *
8  *
9  * Supports:
10  * ---------
11  * '.' Dot, matches any character
12  * '^' Start anchor, matches beginning of string
13  * '$' End anchor, matches end of string
14  * '*' Asterisk, match zero or more (greedy)
15  * '+' Plus, match one or more (greedy)
16  * '?' Question, match zero or one (non-greedy)
17  * '[abc]' Character class, match if one of {'a', 'b', 'c'}
18  * '[^abc]' Inverted class, match if NOT one of {'a', 'b', 'c'} -- NOTE: feature is currently broken!
19  * '[a-zA-Z]' Character ranges, the character set of the ranges { a-z | A-Z }
20  * '\s' Whitespace, \t \f \r \n \v and spaces
21  * '\S' Non-whitespace
22  * '\w' Alphanumeric, [a-zA-Z0-9_]
23  * '\W' Non-alphanumeric
24  * '\d' Digits, [0-9]
25  * '\D' Non-digits
26  *
27  *
28  */
29 #ifndef RE_H
30 #define RE_H
31 
32 #ifdef __cplusplus
33 extern "C"{
34 #endif
35 
48 typedef struct regex_t* re_t;
49 
51 re_t re_compile(const char* pattern);
52 
54 int re_matchp(re_t pattern, const char* text);
55 
57 int re_match(const char* pattern, const char* text);
58 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif // RE_H
int re_match(const char *pattern, const char *text)
Find matches of the txt pattern inside text (will compile automatically first).
Definition: re.c:74
struct regex_t * re_t
Typedef'd pointer to get abstract datatype.
Definition: re.h:48
re_t re_compile(const char *pattern)
Compile regex string pattern to a regex_t-array.
Definition: re.c:109
int re_matchp(re_t pattern, const char *text)
Find matches of the compiled pattern inside text.
Definition: re.c:79
Definition: re.c:43