4
我leraning PCRE,我不明白爲什麼偏移向量必須是多重的3這是pcredemo.c(rc
爲pcre_exec()
結果):PCRE - 偏移矢量,3的倍數?
/* The output vector wasn't big enough */
if (rc == 0) {
rc = OVECCOUNT/3;
printf("ovector only has room for %d captured substrings\n", rc - 1);
}
/* Show substrings stored in the output vector by number. Obviously, in a real
* application you might want to do things other than print them. */
for (i = 0; i < rc; i++) {
char *substring_start = subject + ovector[2 * i];
int substring_length = ovector[2 * i + 1] - ovector[2 * i];
printf("%2d: %.*s\n", i, substring_length, substring_start);
}
對我來說似乎ovector商店str1_start, str1_end, str2_start, str2_end, ...
,所以陣列可以容納OVECCOUNT/2字符串。爲什麼OVECCOUNT/3?
謝謝。
我沒有在手冊那麼遠,。我下次更好地RTFM。謝謝。 – woky 2012-08-16 19:40:43