fork(2) download
  1. #include <string>
  2. #include <regex>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main() {
  7. std::string s{ "AAPL 150918C00099500" };
  8. std::regex pat{ R"(([a-zA-Z0-9]{1,6})\s*(\d{6})([CP]{1})(\d{8}))" };
  9. bool isMatch = std::regex_match( s, pat );
  10. std::sregex_iterator it( s.begin(), s.end(), pat );
  11. for( ; it != std::sregex_iterator{}; ++it )
  12. {
  13. std::cout << ( *it )[1] << "\n" << ( *it )[2]<< "\n" << ( *it )[3] << "\n" << ( *it )[4] << std::endl;
  14. }
  15. return 0;
  16. }
Success #stdin #stdout 0s 3544KB
stdin
Standard input is empty
stdout
AAPL
150918
C
00099500