后缀 ($') 在 C++ 中不起作用regex_replace
Suffix ($´) in c++ regex_replace doesn't work
根据c++regex_replace规范,$´
应该指定匹配的后缀。但它不起作用:
#include <iostream>
#include <string>
#include <regex>
#include <iterator>
int main ()
{
std::string s ("there is a subsequence in the stringn");
std::regex e ("\b(a )(subsequence)(.*)");
// with flags:
std::cout << std::regex_replace (s,e,"$´1digit$03",std::regex_constants::format_default);
std::cout << std::endl;
return 0;
}
输出:
there is $´1digit in the string
它从字面上打印$´
,而不是后缀。我怎样才能做到这一点?
N.B:我在键盘上找不到这个´
字符(从cplusplus.com的regex_replace规范页面复制)
它应该是一个简单的撇号'
:
std::cout << std::regex_replace (s,e,"$'1digit$03",std::regex_constants::format_default)
这个打印:
v--the unmatched part
v v------the $' part (note that it includes a n)
/------ /-------------
there is in the string
1digit in the string
__________________/
^---- the 1digit$03 part
所以很有可能是cpluspluc.com上那个页面的制作者只是打字错误。
cplusplus.com似乎存在一些印刷问题。:-(
正确的字符是
$` prefix
$& matched characters
$' suffix
这是一个替代参考。
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- C++为什么尽管我调用了void函数,它却不起作用
- 为什么在保护模式下继承升级不起作用
- 循环在计数器中不起作用
- 在其他文件中创建类时在 c++ 项目中不起作用
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 为什么二进制搜索在我的测试中不起作用
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 带有指定长度字符* 参数的 std::regex_search 在 VS2017 中不起作用?
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- 为什么简单的算术减法在"if"条件下不起作用?
- 为什么Stroustup书中的has_f不起作用
- 你能检查一下为什么在这个代码中从链接列表中删除项目不起作用吗
- 嵌套While循环不起作用(C++问题)
- C++Matching Brackets 2解决方案不起作用
- 为什么这段代码不起作用,我该如何解决?
- 我正在开发服务器,ip作为参数传递不起作用