Extracting date from the format

68 Views Asked by At

I am struggling through this date extraction. I have a date like this ("D("yyyy-mm-dd")). I want to get this "yyyy-mm-dd" and I cannot strip ("D(") this also because I have this format in other places so I tried like this first searching the string but I am not sure if I am on right track eg. intabc = istrdate.SearchSubString("D("); so please suggest how can I get this value.

Input is "(D(YYYY-MM-DD))" OUTPUT that I want (YYYY-MM-DD)

What i have done(not correct way I think ) intabc = istrdate.SearchSubString("D(");

1

There are 1 best solutions below

1
NaWeeD On BEST ANSWER

you can use substr() and string::erase() functions in c++98

string str = "\"D(\"yyyy-mm-dd\")";
string result = str.substr(3);  
result.erase(result.end() - 1)
result.erase(result.end() - 1)

if you are using c++11 you can also use string::pop_back() method.