|
Boost Users : |
From: Winson Yung (winson.yung_at_[hidden])
Date: 2006-08-10 12:50:55
Thanks John, I was going to ask about this magic '1' number thing. I think I
found an example somewhere like this, but appearantely it was wrong. I was
having so much difficulty using the cregex_iterator, even without the last
match flag, the same code was asserting when it was walking through the
iterator to get the posistion(0). Here is an example of the calltrace when
assert happened:
_assert(void * 0x0067a74c `string', void * 0x0067a758 `string', unsigned int
253) line 256
boost::shared_ptr<boost::regex_iterator_implementation<char const
*,char,boost::regex_traits<char,boost::w32_regex_traits<char> > >
>::operator->() line 253 + 31 bytes
boost::regex_iterator<char const
*,char,boost::regex_traits<char,boost::w32_regex_traits<char> >
>::operator*() line 129 + 37 bytes
CDownloadProgressDlg::ExtractReportKeyStats(unsigned char * 0x02470040,
unsigned __int64 1292879, unsigned char 205) line 1386 + 8 bytes
CDownloadProgressDlg::ExtractReportKeyStats(const char * 0x010ed664,
unsigned char 205) line 1333 + 36 bytes
Question here are:
1) do I need to put parensis around like this to instantiate regex obj like
the following?
expr("(hello world here)", regex_constants::perl | regex_constants::icase);
2) say pBuf has something like the following, will my sample code get the
position of the matching on line 1, 3, 5?
hello skjdfskldjf hello world here kjsfsdf
w3423422 sfsdfsfs hello hello kjkjkjkjkl
world world hello world here 23432423
3333333333333332334234244436435353
hello world here -----------------------------------
thanks for the help!
/Winson
On 8/10/06, John Maddock <john_at_[hidden]> wrote:
>
> Winson Yung wrote:
> >> 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;
>
> Error here:^
>
> The last arg to the iterator constructor is optional, and should be one or
> more of the match_flag enum's:
> http://www.boost.org/libs/regex/doc/match_flag_type.html
>
> John.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
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