Boost logo

Boost Users :

Subject: Re: [Boost-users] find substring and substring position
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-01-12 21:03:40


AMDG

M wrote:
> In:
> http://www.boost.org/doc/libs/1_37_0/doc/html/string_algo/usage.html#id3676944
>
> there is an example: Find Iterator
>
> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> string str1("abc-*-ABC-*-aBc");
> // Find all 'abc' substrings (ignoring the case)
> // Create a find_iterator
> typedef find_iterator<string::iterator> string_find_iterator;
> for(string_find_iterator It=
> make_find_iterator(str1, first_finder("abc", is_iequal()));
> It!=string_find_iterator();
> ++It)
> {
> cout << copy_range<std::string>(*It) << endl;
> }
>
> // Output will be:
> // abc
> // ABC
> // aBC
> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
>
> how do i find the position of each "abc" in: str1 ?
>

Inside the loop, It->begin() is a std::string::iterator to the beginning of
the current match.

In Christ,
Steven Watanabe


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