fork download
  1. #include <iostream> /* C++ iostream C++98/11 */
  2. #include <string> /* C++ strings C++98/11 */
  3. #include <boost/regex.hpp>
  4. #include <boost/algorithm/string/find.hpp>/* RegEx Boost */
  5.  
  6. int main() {
  7.  
  8. /* Our strings and string forms for the regualr expressions. */
  9. std::string id{"station_RTL-158456_datumi_datumi"};
  10. boost::iterator_range<std::string::const_iterator> firstOccurence = boost::find_nth(id, "_", 0);
  11. boost::iterator_range<std::string::const_iterator> secondOccurence = boost::find_nth(id, "_", 1);
  12. std::string program_id{firstOccurence.end(), secondOccurence.begin()};
  13. std::cout << program_id;
  14.  
  15. }
Success #stdin #stdout 0.01s 5432KB
stdin
Standard input is empty
stdout
RTL-158456