Home > OS >  \K operator does not work in std::regex_replace regex
\K operator does not work in std::regex_replace regex

Time:06-15

The value of name is: regex101: build, test, and debug regex - 3 running windows im trying to remove everything forward the last -

std::wstring name = accvector[i].name;
std::wregex regexp(L".*\\K( -\\s \\d \\srunning.*$)");
name = std::regex_replace(name, regexp, L"");

nothing is being replace, whats wrong?

CodePudding user response:

You should keep in mind that enter image description here

Note you do not need the $ at the end of the pattern, .* matches till the end of the line/string.

  • Related