Boost logo

Boost Users :

From: Winson Yung (winson.yung_at_[hidden])
Date: 2006-08-09 22:18:19


Hi all, I am trying to use cregex_iterator, but reading the doc doesn't seem
to help me understand the usage of the API.
If I supply a regular expression, is the following code correctly get the
starting position of each occurance of the string "hello world here" in the
buffer?

sample code like this:

int nextPos[100];
char *pBuf = NULL; // pBuf will be point to a buffer NULL terminated
............................
regex expr("hello world here", regex_constants::perl |
regex_constants::icase);
cregex_iterator h1(pBuf, pBuf + std::strlen(pBuf), expr, 1), h2;

int i = 0;
while (i < 100 && h1 != h2)
{
    nextPos[i] = (*h1).position(0);
    h1++;
    i++;
}



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net