fork(2) download
  1. #include <iostream>
  2. #include <map>
  3. #include <regex>
  4. #include <string>
  5.  
  6. int main()
  7. {
  8. const std::map<int, std::string> m = {{1, "New York"}, {2, "summer"}};
  9. std::string s = "I am in #1 city, it is now #2 time";
  10.  
  11. for (const auto& [id, value] : m) {
  12. s = std::regex_replace(s, std::regex("#" + std::to_string(id)), value);
  13. }
  14. std::cout << s << std::endl;
  15. }
  16.  
Success #stdin #stdout 0s 4344KB
stdin
Standard input is empty
stdout
I am in New York city, it is now summer time