summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--regexp.c14
2 files changed, 15 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 9ff95e4..07d4312 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
BINS = ascii class depipe_strings dup fpipe pipe realloc strpbrk strsep \
tokenizer getopt prime_mask linked_list pi_bbp string_tokenizer \
- tcpserver tcpclient
+ tcpserver tcpclient regexp
CC = gcc
CFLAGS = -Wall -std=gnu99 -pedantic
DBGFLAGS = -g -O0
diff --git a/regexp.c b/regexp.c
new file mode 100644
index 0000000..ffaa1fc
--- /dev/null
+++ b/regexp.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ char name[50 + 1], email[50 + 1];
+ char *string = "\"Bro Brotato\" <bro@hax.org>";
+
+ /* i'm telling sscanf how string looks, %[] is the regexp */
+ sscanf(string, "\"%50[^\"<]\" <%50[^>]", name, email);
+
+ printf("name: \"%s\"\n", name);
+ printf("email: \"%s\"\n", email);
+}
+