这
std::regex line("[\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s]");
Run Code Online (Sandbox Code Playgroud)
线导致这个
Exception thrown at 0x00007FFE39E69E08 in DosyaOkuHizli.exe: Microsoft C++ exception: std::regex_error at memory location 0x000000F751EFEAB0.
Exception thrown at 0x00007FFE39E69E08 in DosyaOkuHizli.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
Exception thrown at 0x00007FFE39E69E08 in DosyaOkuHizli.exe: Microsoft C++ exception: std::regex_error at memory location 0x000000F751EFEAB0.
Unhandled exception at 0x00007FFE39E69E08 in DosyaOkuHizli.exe: Microsoft C++ exception: std::regex_error at memory location 0x000000F751EFEAB0.
Run Code Online (Sandbox Code Playgroud)
但是这个
std::regex line("abc");
Run Code Online (Sandbox Code Playgroud)
才不是。
长表达式在这里工作: https: //www.myregextester.com/index.php
我只是想获取其他数据之间的 3 个后续浮点值。
Visual Studio 2015 社区版调试 64 位。Windows 10。
\\您需要使用(二合一)转义反斜杠,或者使用原始字符串文字,如下所示:
regex line{R"([\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s])"};
Run Code Online (Sandbox Code Playgroud)
原始字符串文字用(至少)R"(和包围字符串)"。
阅读有关原始字符串文字的更多信息,请参见此处- 语法 (6)。