使用wstring替换regex_replace需要帮助
need assist using regex_replace with wstring
我想使用regex_replace,就像这里链接的例子一样,使用using string/c-string(3)版本:http://www.cplusplus.com/reference/regex/regex_replace/
问题是,我对模板和regex类的理解不够好,无法在每个示例中使用regex_replace,但使用了一个宽字符串。我看到了花环,但我不知道如何使用它。
其想法是获取字符串regex_{13E008E3-EEE7-4AC3-B9F1-E353DB67EDFD}并将其转换为状态_{13E808E3-EEE7-4AC3-B6F1-E353DB267EDFD}
wstring statusDataName;
wstring key = wstring(L"regex_");
wstring repl = wstring(L"status_");
TCHAR dataName[MAX_STR] = {0};
statusDataName = regex_replace(wstring(dataName), key, repl);
错误C2784:'std::basic_string<_Elem,std::char_traits<_Elem>,std::分配器<_其他>>std::regex_replace(const_Elem*,conststd::basic_regx<_Elem,RxTraits>&,常量勒姆(_E)*,std::regex_constants:match_flag_type)':无法从中推导出'const_Elem*'的模板参数'std::basic_string,std::allocater>'错误C2784:'std::basic_string<_Elem,std::char_traits<_Elem>,std::分配器<_其他>>std::regex_replace(const_Elem*,conststd::basic_regx<_Elem,RxTraits>&,conststd::basic_string<_Elem,_Traits1,_Alloc1>&,std::regex_constants::match_flag_type)':无法推导模板来自的"const_Elem*"的参数'std::basic_string,std::allocater>'错误C2784:"std::basic_string<_Elem,_Traits1,_Alloc1>std::regex_replace(const std::basic_string<_Elem,_Traits1,_Alloc1>&,const std::basic_regx<_Elem,RxTraits>&,常量勒姆(_E)*,std::regex_constants::match_flag_type)":无法推导"const std::basic_regex<_Elem,_RxTraits>&'从…起"std::wstring"错误C2784:"std::basic_string<_Elem,_Traits1,_Alloc1>std::regex_replace(const std::basic_string<_Elem,_Traits1,_Alloc1>&,const std::basic_regx<_Elem,RxTraits>&,conststd::basic_string<_Elem,_Traits2,_Alloc2>&,std::regex_constants::match_flag_type)':无法推导模板const std::basic_regx<的参数_Elem,_RxTraits>&'从…起"std::wstring"错误C2780:"_OutIt"std::regex_replace(_OutIt,_BidIt,_BidIt,conststd::basic_regx<_Elem,RxTraits>&,常量勒姆(_E)*,std::regex_constants::match_flag_type)':需要6个参数-提供了3个错误C2780:"_OutTy*std::regx_replace(_OutTy(&)[_OutSize],_BidIt,_BidIt,const std::basic_regx<_Elem,_RxTraits>&,const std::basic_string<_Elem,_Traits,_Alloc>&,std::regex_constants::match_flag_type)':需要6个参数-3提供的错误C2780:'_OutItstd::regex_replace(_OutIt,_BidIt,_BidIt,conststd::basic_regx<_Elem,RxTraits>&,conststd::basic_string<_Elem,_Traits,_Alloc>&,std::regex_constants::match_flag_type)':需要6个参数-3提供
我该怎么解决这个问题?
工作变体:
#include <string>
#include <regex>
#include <iostream>
using std::wstring;
int main()
{
wstring dataName = L"regex_{13E008E3-EEE7-4AC3-B9F1-E353DB67EDFD} ";
wstring key = wstring(L"regex_");
wstring repl = wstring(L"status_");
wstring statusDataName = std::regex_replace(dataName, std::wregex(key), repl);
std::wcout << statusDataName << L"n";
}
- 需要帮助设置在C++中使用的Potrace
- 在指针的帮助下,文本文件中单词的频率
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 如何在Qbutton的帮助下更改Q对话框的宽度
- 需要帮助将结构数组传递给函数
- C++需要帮助从用户那里获得一个整数,并确保它在另外两个整数之间
- 需要帮助在 c++ 中将字符串转换为字符 ----错误 "const char *" 类型的值不能用于初始化 "char" 类型的实体
- 有人可以帮助我处理正则表达式吗?
- C++调用具有 *this 属性的单个帮助程序函数
- C++:需要帮助了解运算符重载错误
- 需要以下代码的帮助,下面的代码有什么问题
- CS1 项目帮助C++
- 用于检查值是否为其任何参数的帮助程序函数
- 需要有关此 if 语句的帮助
- 类型限定宏帮助程序
- CoreCLR 中的检测探查器 - 将帮助程序程序集加载到 dotnet 进程的方法
- NS3 插槽混淆(需要帮助理解)
- 设计帮助 - 为不同类型的消息处理通用接口的设计模式
- 需要帮助查找内存泄漏
- 有人可以帮助我理解这些参数/参数吗?