summaryrefslogtreecommitdiffstats
path: root/regexp.c
diff options
context:
space:
mode:
Diffstat (limited to 'regexp.c')
-rw-r--r--regexp.c14
1 files changed, 14 insertions, 0 deletions
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);
+}
+