PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
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'}
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 * '{n}' Exact quantifier
27 * '{n,m}' Range quantifier
28 * '|' Branch (alternation)
29 * '(...)' Group
30 *
31 */
32
33#ifndef _TINY_REGEX_C
34#define _TINY_REGEX_C
35
36
37#ifndef RE_DOT_MATCHES_NEWLINE
38/* Define to 0 if you DON'T want '.' to match '\r' + '\n' */
39#define RE_DOT_MATCHES_NEWLINE 1
40#endif
41
42#ifdef __cplusplus
43extern "C"{
44#endif
45
46
47
48/* Typedef'd pointer to get abstract datatype. */
49typedef struct regex_t* re_t;
50
51
52/* Compile regex string pattern to a regex_t-array. */
53re_t re_compile(const char* pattern);
54
55
56/* Find matches of the compiled pattern inside text. */
57int re_matchp(re_t pattern, const char* text, int* matchlength);
58
59
60/* Find matches of the txt pattern inside text (will compile automatically first). */
61int re_match(const char* pattern, const char* text, int* matchlength);
62
63
64#ifdef __cplusplus
65}
66#endif
67
68#endif /* ifndef _TINY_REGEX_C */
int re_match(const char *pattern, const char *text, int *matchlength)
struct regex_t * re_t
Definition re.h:49
re_t re_compile(const char *pattern)
int re_matchp(re_t pattern, const char *text, int *matchlength)