[英]Long regex expression causes error
這個
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。
您要么需要用\\\\
轉義反斜杠(一對二),要么使用像這樣的原始字符串文字:
regex line{R"([\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s]+\+?[0-9]+.[0-9]+[\s])"};
原始字符串文字(至少)用R"(
和)"
包圍字符串。
在此處閱讀有關原始字符串文字的更多信息-語法(6)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.