Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
702 B
Referenced Files
None
Subscribers
None
diff --git a/util/regex.cpp b/util/regex.cpp
index 1748a128..33aa6706 100644
--- a/util/regex.cpp
+++ b/util/regex.cpp
@@ -1,8 +1,17 @@
#include <string>
+/* gnu/posix's regex header */
+#include <regex.h>
+/* our regex header */
#include "regex.h"
using namespace std;
-bool Util::matchRegex(const string & str, const string & regex){
- return false;
+/* http://www.gnu.org/s/libc/manual/html_node/Regular-Expressions.html */
+bool Util::matchRegex(const string & str, const string & pattern){
+ regex_t regex;
+ if (regcomp(&regex, pattern.c_str(), 0) != 0){
+ return false;
+ }
+ bool matched = regexec(&regex, str.c_str(), 0, NULL, 0) == 0;
+ return matched;
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 1:34 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69271
Default Alt Text
(702 B)

Event Timeline