slre - Super Light Regular Expression library URL: http://slre.sourceforge.net/ Just ported to mbed.

Dependencies:   mbed

Revision:
0:e0b85a04e7e5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Nov 18 18:01:01 2009 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "slre.h"
+
+DigitalOut led(LED1);
+/*
+class RegEx {
+  RegEx(char *ex);
+  match(char *str, Groups *)
+}
+*/
+int main() {
+    char *buf = "GET /foo.bar?query=moo HTTP/1.5\r\n";
+    struct slre        slre;
+    struct cap         captures[4 + 1];
+
+    if (!slre_compile(&slre, "^(GET|POST) (\\S+) HTTP/(\\S+?)\r\n")) {
+        printf("Error compiling RE: %s\n", slre.err_str);
+    } else if (!slre_match(&slre, buf, strlen(buf), captures)) {
+        printf("Not a valid HTTP request\n" );
+    } else {
+        printf("Request line length: %d\n", captures[0].len);
+        printf("Method: %.*s\n", captures[1].len, captures[1].ptr);
+        printf("URI: %.*s\n", captures[2].len, captures[2].ptr);
+    }
+    while(1) {
+        led = !led;
+        wait(0.2);
+    }
+}