Skip to content

Instantly share code, notes, and snippets.

@chelovekula
Created September 30, 2020 02:03
Show Gist options
  • Save chelovekula/b81afd4e95f250782fa0efa642235f93 to your computer and use it in GitHub Desktop.
Save chelovekula/b81afd4e95f250782fa0efa642235f93 to your computer and use it in GitHub Desktop.
// string::substr
#include <iostream>
#include <string>
int main ()
{
std::string str="--flag-switches-begin --timezone=\"America/New_York\" --flag-switches-end";
std::size_t pos1 = str.find("--timezone=\"") + 12;
std::size_t pos2 = str.find("\" --flag-switches-end") - pos1;
std::string str2 = str.substr (pos1,pos2);
std::cout << str2 << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment