此
std::regex line("[\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s]");
行导致此
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.
但是这个
std::regex line("abc");
没有。
长表达式适用于此:https://www.myregextester.com/index.php
我只是想在其他数据之间获得3个后续浮点值。
Visual Studio 2015社区版调试64位。 Windows 10。
答案 0 :(得分:3)
您需要使用\\
(两个一个)转义反斜杠,或者使用这样的原始字符串文字:
regex line{R"([\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s])"};
原始字符串文字用(至少)R"(
和)"
围绕字符串。
阅读有关原始字符串文字HERE的更多信息 - 语法(6)。