I am using regex under vxworks and have no possibility to include "regex.h".
I am getting the compilerwarning "unrecognized character escape sequence" for the code if (sscanf(token, "%*[^\[][%d]", &idx) != 1)
because of the '\' and the following '['.
Is there a possibility to get rid of that compilerwarning without using the regex.h and stuff like it is done here: Unable to match regex in C
You may want to try something like
#include <stdio.h>
int main(void) {
char buf[99];
int idx, n;
while (fgets(buf, sizeof buf, stdin)) {
buf[strcspn(buf, "\n")] = 0; // remove ENTER
if (sscanf(buf, "%*[^[][%d%n", &idx, &n) != 1) {
printf("no number in %s\n", buf);
} else {
printf("number found: %d (left over string: \"%s\")\n", idx, buf + n);
}
}
return 0;
}