blob: 9b70d6817fbf2a12a83eb8d24536aff3bc094486 (
plain)
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
|
#include "Regex.h"
char t[1024];
Regex empty("$^"), any(".*");
Regex::Regex(const String & regex, int cflags, int aeflags) throw (GeneralException) : eflags(aeflags) {
int r;
if ((r = regcomp(&preg, regex.to_charp(), cflags | REG_NOSUB))) {
regerror(r, &preg, t, sizeof(t));
throw GeneralException(String("Regex \"") + regex + "\" failed to compile: " + t + "\n");
}
}
Regex::~Regex() {
regfree(&preg);
}
bool Regex::Match(const String & s) const {
if (regexec(&preg, s.to_charp(), 0, 0, eflags)) {
return false;
} else {
return true;
}
}
|