【发布时间】:2013-07-20 03:10:12
【问题描述】:
我尝试使用普通的正则表达式,一切都很好,当我切换到 wregex 在 Unicode 字符中搜索和标记时,它失败了,我不明白为什么。
有人可以指出我在这里缺少什么吗?
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]]++ ;
}
}
我的文件内容是波斯语,如:
بسم الله الرحمن الرحیم
تست یک تست 2 . 2357 نفر آمار تست اولیه هرچی!!
这些是它产生的错误:
error C2679: binary '[' : no operator found which take a right-hand 'const std::sub_match<_bidit>' 类型的操作数(或者没有 可接受的转换)
IntelliSense:没有运算符“[]”与这些操作数的操作数类型匹配 是:std::map, 标准::分配器>> [常量 std::sub_match>>> ]
【问题讨论】:
-
它是如何失败的?你能从你的非英语文件和你期望的输出中给出一个示例行吗?
-
它在编译时停止了!我会在几秒钟内将错误添加到问题中
-
您使用的是哪个编译器和版本?在哪个平台下?
-
Visual C++2012 UpdatePack3
-
这就是你如何使用 wstring 和 ifstream stackoverflow.com/questions/5382451/…
标签: regex visual-c++ c++11