dポイントプレゼントキャンペーン実施中!

boost_1_47を利用して、置換を行おうとしているのですが、「VIII」を置換しようとするとエラーになります。たぶん「5B」が入っているからかと思うのですが、どのように対処したらよいのでしょうか?

#include <boost/regex.hpp>
using namespace std;
using namespace boost;

const boost::regexstr("VIII");


よろしくお願いします。

A 回答 (1件)

UNICODE(wide文字)版使う。



// VC++ 2010 で動作確認済

#include <boost/regex.hpp>
#include <iostream>
#include <string>
#include <locale>
#include <exception>

using namespace std;
using namespace boost;

int main() {
try {
const wregex re(L"VIII");
wstring source = L"ヘンリーVIII世と6人の妻";
wstring fmt = L"8";
wstring result = regex_replace(source, re, fmt);
wcout.imbue(locale("japanese"));
wcout << result << endl;
} catch ( std::exception& e) {
cout << e.what() << endl;
}
}
    • good
    • 0
この回答へのお礼

ありがとうございました。

解決しました。


動作確認までしていただいて、助かりました。

お礼日時:2012/07/30 08:40

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!