]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/regex/example/snippets/regex_token_iterator_eg_1.cpp
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE regex_token_iterator_example_1.cpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: regex_token_iterator example: split a string into tokens.
20 #include <boost/regex.hpp>
26 #if defined(BOOST_MSVC) || (defined(__BORLANDC__) && (__BORLANDC__ == 0x550))
28 // problem with std::getline under MSVC6sp3
29 istream
& getline(istream
& is
, std::string
& s
)
32 char c
= static_cast<char>(is
.get());
36 c
= static_cast<char>(is
.get());
43 int main(int argc
, const char*[])
49 cout
<< "Enter text to split (or \"quit\" to exit): ";
51 if(s
== "quit") break;
54 s
= "This is a string of tokens";
56 boost::regex
re("\\s+");
57 boost::sregex_token_iterator
i(s
.begin(), s
.end(), re
, -1);
58 boost::sregex_token_iterator j
;
66 cout
<< "There were " << count
<< " tokens found." << endl
;