fork(1) download
  1. #include <iostream>
  2. #include <regex>
  3. using namespace std;
  4.  
  5. int main(int argv, const char* argc[])
  6. {
  7. regex log_line_regex_(".+\\s(.+)$");
  8. char* log_line = "06-29 18:20:08.938 1031 1099 D WifiStateMachine: processMsgConnect oo ModeState";
  9. smatch matches;
  10. if (regex_match(std::string(log_line), matches, log_line_regex_))
  11. {
  12. std::cout << "match: " << log_line << std::endl;
  13. unsigned i;
  14. for (i = 0; i < matches.size(); i++)
  15. {
  16. std::cout << "$" << i << ": " << std::string(matches[i].first, matches[i].second) << std::endl;
  17. }
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 3368KB
stdin
Standard input is empty
stdout
match: 06-29 18:20:08.938 1031 1099 D WifiStateMachine: processMsgConnect oo ModeState
$0: 06-29 18:20:08.938 1031 1099 D WifiStateMachine: processMsgConnect oo ModeSt`
$1: ModeSt`