The regular expression should be no problem, I use regular expressions of python re. The.findall () can be normal match, don't know why C didn't match the other field information,
Don't know is code problem, or a regular expression, please grant instruction!
The code is as follows:
#include
#include
#include
#include
#include
#include
Int main (int arg c, char * argv [])
{
Char * okcode="[1, 2]; [5, 6]. [7, 10); 3.
"Char * pattern="(\ \ [| \ \ \ \ s * () ([0-9] +) \ \ s *, \ \ s * ([0-9] +) \ \ s * (\ \) | \ \]) | ([0-9] +); {0, 1} ";
Char buf [1024].
Char match [100].
Int res;
Regex_t re;
The static const size_t nmatch=50;
Regmatch_t pmatch [50].
/* compile the regular expression */
Res=regcomp (& amp; Re, the pattern, REG_EXTENDED);
If (res) {
Regerror (res, & amp; Re, buf, sizeof (buf));
Fprintf (stderr, "% s: the pattern of '% s' \ n", buf, the pattern).
return 1;
}
Application/* regular expression matching */
Res=regexec (& amp; Re, okcode nmatch, pmatch, 0);
If (res==REG_NOMATCH) {
Printf (" no match \ n ");
Regfree (& amp; Re);
return 2;
}
Else if (res!=0) {
Regerror (res, & amp; Re, buf, sizeof (buf));
Fprintf (stderr, "res: % s \ n", buf);
Regfree (& amp; Re);
Return 3;
}
/* output processing result */
int i;
For (I=0; I & lt; Nmatch & amp; & Pmatch [I] rm_so!=1; + + I) {
Int len=pmatch [I] rm_eo - pmatch [I] rm_so;
If (len) {
Memset (match, 0, sizeof (match));
Memcpy (match, okcode + pmatch [I] rm_so, len);
Printf (" [] % d: % s \ n ", I, match);
}
}
/* release regular expression */
Regfree (& amp; Re);
return 0;
}