Debianではlibboost-devとlibboost-regex-devパッケージをインストールしておきます。
#include <boost/regex.hpp> #include <string> #include <iostream> using namespace boost; using namespace std; int main(){ regex re("<(.*?)>"); const string source = "<tag>body</tag>"; const string format = "<$1>"; string result = regex_replace(source, re, format); cout << result << endl; return 0; }
んで、コンパイルして実行してみます。
日本語も特に問題なく使えているみたい。文字コードがUTF-8だからかな?
$ g++ regex.cpp -lboost_regex -oregex
$ ./regex
<tag>body</tag>