I have an input string like 051916.000
. I would like to segregate 05
, 19
, 16
and 000
.
I am trying to use regexec
in this way in C language.
regex_t r;
regmatch_t pmatch[4];
char* pattern = "/([0-9]{2})([0-9]{2})([0-9]{2})\\.(.*)";
int status = regcomp(&r, "", REG_EXTENDED|REG_NEWLINE);
status = regexec(&r, t, 4, pmatch, 0);
regfree(&r);
But this does not seem to work. Below is the GDB output
(gdb) p pmatch
$1 = {{rm_so = 0, rm_eo = 0}, {rm_so = -1, rm_eo = -1}, {rm_so = -1, rm_eo = -1}, {rm_so = -1, rm_eo = -1}}
I have used Regex in Python. I am new to Regex in C. So I am not sure where I am going wrong. Regex is verified, and it matches correctly.