-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
85 lines (63 loc) · 2.1 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
aov-rx README
=============
aov-rx is a malloc-free [1], wide-char based regular expression matching
library. This piece of code is designed to be part of MPDM [2] in the
future, but can also be used separately.
Please see the TODO file to know the completion status of this project.
Released under the public domain.
Angel Ortega <[email protected]>
[1] Free as in 'without', not as in 'free()'
[2] http://triptico.com/software/mpdm.html (Minimum Profit Data Manager)
Goals
-----
- Not using dynamic memory,
- using wide chars (wchar_t) natively,
- returns the matching substring as offset + size,
- source code being readable, and
- being completely reentrant and thread-safe.
Features
--------
- Start (^) and end of string ($) anchors
- . (match any character)
- Full quantifier support:
- Curly bracket with optional minimum and maximum:
- Exactly n matches ({n})
- At least n matches ({n,})
- At most m matches ({,m})
- At least n and at most m matches ({n,m})
- ? (match 0 or 1 occurrences, same as {0,1})
- * (match 0 or many occurrences, same as {0,})
- + (match 1 or many occurrences, same as {1,})
- Alternate sets (str1|str2|str3)
- Sub-regexes (between parentheses, also optionally
quantifiable)
- Bracket-wrapped character sets, positive and
negative ([0-9], [^0-9])
Features that will (probably) be, but not soon
----------------------------------------------
- Optional multiline matching (i.e. ^ and $ matching lines inside
the string instead of the start and the end of the string)
Features that (probably) will never be
--------------------------------------
- Backreferences
Usage
-----
aov-rx consists only of one function:
wchar_t *aov_match(wchar_t *rx, wchar_t *tx, size_t *size);
And its usage is pretty straightforward:
#include <stdio.h>
#include <wchar.h>
#include "aov-rx.h"
int main(int argc, char *argv[])
{
size_t s;
wchar_t *res;
res = aov_match(L"[0-9]+", L"The number is 123, indeed", &s);
if (s) {
/* res points to 123, and s contains 3 */
...
}
...
---
Angel Ortega
http://triptico.com