⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 find_example.cpp

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻 CPP
字号:
//  Boost string_algo library example file  ---------------------------------////  Copyright Pavol Droba 2002-2003. Use, modification and//  distribution is subject to the Boost Software License, Version//  1.0. (See accompanying file LICENSE_1_0.txt or copy at//  http://www.boost.org/LICENSE_1_0.txt)//  See http://www.boost.org for updates, documentation, and revision history.#include <string>#include <iostream>#include <algorithm>#include <functional>#include <boost/algorithm/string/case_conv.hpp>#include <boost/algorithm/string/find.hpp>using namespace std;using namespace boost;int main(){      cout << "* Find Example *" << endl << endl;    string str1("abc___cde___efg");    string str2("abc");    // find "cde" substring    iterator_range<string::iterator> range=find_first( str1, string("cde") );    // convert a substring to upper case     // note that iterator range can be directly passed to the algorithm    to_upper( range );    cout << "str1 with upper-cased part matching cde: " << str1 << endl;    // get a head of the string    iterator_range<string::iterator> head=find_head( str1, 3 );    cout << "head(3) of the str1: " << string( head.begin(), head.end() ) << endl;    // get the tail    head=find_tail( str2, 5 );    cout << "tail(5) of the str2: " << string( head.begin(), head.end() ) << endl;    // char processing    char text[]="hello dolly!";    iterator_range<char*> crange=find_last(text,"ll");    // transform the range ( add 1 )    transform( crange.begin(), crange.end(), crange.begin(), bind2nd( plus<char>(), 1 ) );    // uppercase the range    to_upper( crange );    cout << text << endl;    cout << endl;    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -