如何在C+中使用wregex+;11?
我试着使用一个普通的正则表达式,一切都很好,当我切换到一个wregex在Unicode字符之间搜索和标记时,它失败了,我不明白为什么。如何在C+中使用wregex+;11?,regex,visual-c++,c++11,Regex,Visual C++,C++11,我试着使用一个普通的正则表达式,一切都很好,当我切换到一个wregex在Unicode字符之间搜索和标记时,它失败了,我不明白为什么。 有人能指出我遗漏了什么吗 map<string, int> container; wifstream file("ftest.txt"); wregex reg(_T("\\w+")); wstring s=_T(""); while (file.good()) { file>>s; for ( wsregex_iter
有人能指出我遗漏了什么吗
map<string, int> container;
wifstream file("ftest.txt");
wregex reg(_T("\\w+"));
wstring s=_T("");
while (file.good())
{
file>>s;
for ( wsregex_iterator it (s.cbegin(), s.cend(), reg),it_end; it != it_end; ++it)
{
container[(*it)[0]]++ ;
}
}
以下是它产生的错误:
错误C2679:二进制“[”:找不到使用右手的运算符
“const std::sub_match”类型的操作数(或没有
可接受的转换)
IntelliSense:没有运算符“[]”匹配这些操作数操作数类型
是:std::map,
std::分配器>>[const
std::sub_匹配>>>]
s、 begin()和s.end()应返回wstring迭代器(使s成为wstring)
这就是如何将wstring与ifstream一起使用
映射也应该是
map
。它是如何失败的?您能给出一个非英语文件中的示例行以及您期望的输出吗?它在编译时停止了!我在几秒钟后将错误添加到问题中您使用的是哪种编译器和版本?在哪种平台下?Visual C++2012 UpdatePack3这是如何将wstring与if一起使用的stream谢谢,但我在尝试将cout与我的地图一起使用时出错了!?coutyou可以使用ifstream技巧,但相反。使用cout或者更好地使用std::wcout:)
بسم الله الرحمن الرحیم
تست یک تست 2 . 2357 نفر آمار تست اولیه هرچی!!