How to get specific value by using index

53 Views Asked by At

I want to extract my date that is "2017-11-10" value from this type of string "(D(2017-11-10)".

I am trying to directly hit the value starting from 2017 as I do not want
"(D(" in the final string but I don't know how can I do it.

I have tried like this

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

but this searches only the starting part of "(D(2017-11-10)" which is ok

but now how can I get "2017-11-10" that is my date.

1

There are 1 best solutions below

0
MivVG On

Using a regex is the easiest solution:

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