summaryrefslogtreecommitdiffstats
path: root/regexp.c
blob: ffaa1fc56b6b15e0c327434168b57b3a935324e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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);
}