]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/regex/example/snippets/regex_split_example_1.cpp
3 * Copyright (c) 1998-2002
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_split_example_1.cpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: regex_split example: split a string into tokens.
20 #include <boost/regex.hpp>
24 unsigned tokenise(std::list
<std::string
>& l
, std::string
& s
)
26 return boost::regex_split(std::back_inserter(l
), s
);
33 #if defined(BOOST_MSVC) || (defined(__BORLANDC__) && (__BORLANDC__ == 0x550))
35 // problem with std::getline under MSVC6sp3
36 istream
& getline(istream
& is
, std::string
& s
)
39 char c
= static_cast<char>(is
.get());
43 c
= static_cast<char>(is
.get());
50 int main(int argc
, const char*[])
57 cout
<< "Enter text to split (or \"quit\" to exit): ";
59 if(s
== "quit") break;
62 s
= "This is a string of tokens";
63 unsigned result
= tokenise(l
, s
);
64 cout
<< result
<< " tokens found" << endl
;
65 cout
<< "The remaining text is: \"" << s
<< "\"" << endl
;