::std::regex_replace with syntax flag icase on Windows(VS201
::std::regex_replace with syntax flag icase on Windows (VS2013 Update 4, VS2015 Update 3) does not match using character ranges
我在VS2013更新4和VS2015更新3中使用以下C++代码,使用字符范围来尝试不区分大小写匹配并替换出现的内容:
std::wstring strSource(L"Hallo Welt, HALLO WELT");
std::wstring strReplace(L"ello");
std::regex_constants::syntax_option_type nReFlags =
std::regex::ECMAScript |
std::regex::optimize |
std::regex::icase;
std::wregex re(L"[A]LLO", nReFlags);
std::wstring strResult = std::regex_replace(strSource, re, strReplace);
wcout << L"Source: "" << strSource.c_str() << L""" << endl
<< L"Result: "" << strResult.c_str() << L""" << endl;
我期望输出:
Source: "Hallo Welt, HALLO WELT"
Result: "Hello Welt, Hello WELT"
但我得到了:
Source: "Hallo Welt, HALLO WELT"
Result: "Hello Welt, HALLO WELT"
为什么字符范围没有应用区分大小写?为什么第二场比赛似乎没有找到并被替换?
我觉得这可能是Visual Studio中的一个错误。如果将括号从[A]
中移除,则效果良好。
std::wregex re(L"ALLO", nReFlags);
奇怪的是,如果你使用regex_search
,它会找到2个匹配项。。。
std::wregex re(L"([A]LLO)", nReFlags);
std::wsmatch match;
std::regex_search(strSource, match, re);
for (auto i = 0; i < match.size(); ++i)
std::wcout << match[i] << "n";
相关文章:
- 瓦尔格林德:数学函数"Conditional jump or move depends on uninitialised value(s)"
- 循环挂起迭代的 std::擦除 on std::list
- SIGSEGV on Boost UDP 套接字关闭 - tcache_get at malloc.c.
- CPP 中的瓦尔格林德和记忆泄漏:"Conditional jump or move depends on uninitialised values"
- std::bind on statd::array 的运算符 []
- 您将如何连接"on the fly"文本+整数并将其传递给函数?
- 如何修复输出日志中的"EnableInput can only be specified on a Pawn for its Controller"错误
- VS2019 - Sudo Remote Debugging on Linux with Cmake project
- C++ library with Tensorflow on Android
- SFML 交叉编译 for Windows on Linux.
- How to recover system gcc compiler on centos 6
- Cmake with Flex/Bison on windows
- 按原样保存用户输入 - Ruby on Rails
- OpenAL C++ on Linux
- Boost::process on Windows - with MinGW?
- CMake on FindOpenGL.cmake 中的错误,当使用导入的目标 OpenGL::GLU?
- Utilization of atomic_flag on C++
- anaconda cythonize C++ on windows 10
- CMake & MinGW Compileilation on Windows,无需 -G "MinGW Makefiles"标志
- ::std::regex_replace with syntax flag icase on Windows(VS201