fork(4) download
  1. #include <iostream>
  2. #include <regex>
  3. using namespace std;
  4.  
  5. int main() {
  6. std::string l_strHexValue = "#FF0000";
  7. std::regex pattern("#([0-9a-fA-F]{6})\\b");
  8. std::smatch match;
  9. if (std::regex_match(l_strHexValue, match, pattern))
  10. {
  11. int r, g, b;
  12. sscanf(match.str(1).c_str(), "%2x%2x%2x", &r, &g, &b);
  13. std::cout << "R: " << r << ", G: " << g << ", B: " << b << "\n";
  14. }
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 5460KB
stdin
Standard input is empty
stdout
R: 255, G: 0, B: 0