#include bool validColor(std::string color); std::string okay(std::string s); int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); validColor("rgb(0,,0)"); return a.exec(); } std::string okay(std::string s) { std::string temp; for(int i = 0; i rgb; for(int i = 0; i<3; i++){ int position = color.find(','); // if a comma isn't found, stop. if(std::string::npos == position)break; // empty string is invalid parameter if(!position) return false; // a comma was found, copy everything before comma. rgb.push_back(okay(color.substr(0,position))); // delete the commma and everything before it. color = color.substr(position+1,std::string::npos); } // this is the third/fourth number if(color.size()){rgb.push_back(fokay(color));} if(rgb.size() != expected) return false; for(int j = 0;jrgbA || rgbA>1){return false;} } else { int aNumber = std::stoi(rgb[j], nullptr, 10); // if aNumber is greater than 255 or less than 0, then its not valid if(0>aNumber || aNumber>255) return false; // [?] see (numbers_above_100_percent) if(checkPercent && aNumber>100) return false; } } return true; }