如何使用索引获得特定值

How to get specific value by using index

本文关键字:何使用 索引      更新时间:2023-10-16

我想从这种类型的字符串中提取" 2017-11-10"值的日期 "(D(2017-11-10)"。

我试图从2017年开始直接达到价值,因为我不想要
"(d("在最后的字符串中,但我不知道该怎么做。

我尝试过这样的尝试

int date= istr.SearchSubString("D(");

但这仅搜索"(D(2017-11-10)"的起始部分,这还可以

但是现在我该如何获得" 2017-11-10",这是我的日期。

使用正则表达式是最简单的解决方案:

std::string date = "(D(2017-10-11)";
std::regex dateRegex("(D(");
std::string newDate = std::regex_replace(date, dataRegex, ""); //This will replace the (D( with an empty string