[Solved] Does C’s strtok function support regex?


No, it does not support regex. Read the documentation before asking. On the other hand, that’s precisely how it works so again Read the documentation, i.e. You give it all the possible delimiters.

Check it here

#include <stdio.h>
#include <string.h>

int
main(void)
{
    char example[] = "exa$mple@str#ing";
    char *token;
    char *pointer;
    pointer = example;
    token = strtok(pointer, "@#$");
    if (token == NULL)
        return -1;
    do
    {
        fprintf(stdout, "%s\n", token);
        pointer = NULL;
    } while ((token = strtok(NULL, "@#$")) != NULL);

}

1

solved Does C’s strtok function support regex?