fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string extract(const string &s, const string &name)
  6. {
  7. string to_find = name + ":";
  8. string::size_type start = s.find(to_find);
  9. if (start == string::npos) return "";
  10. string::size_type stop = s.find('&', start + to_find.size());
  11. return s.substr(start, stop - start);
  12. }
  13.  
  14. int main() {
  15. string s = "plushieid:5637372&plushieposition:12757&plushieowner:null&totalplushies:5637373";
  16. string found = extract(s, "plushieposition");
  17. cout << found;
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5504KB
stdin
Standard input is empty
stdout
plushieposition:12757