ubuntu 14.04 安装和使用 boost 库

1 安装

sudo apt-get install libboost-dev

2 使用

#include <iostream>
#include <string>
#include "boost/regex.hpp"
int main() {
    boost::regex reg("(Colo)(u)(r)",
    boost::regex::icase|boost::regex::perl);
    std::string s="Colour, colours, color, colourize";
    s=boost::regex_replace(s,reg,"$1$3");
    std::cout << s;
}

把上面内容保存到re.cpp文件中
编译:g++ -o re re.cpp -llibboost_regex
运行:./re
输出:Color, colors, color, colorize

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容